From 61f095fdc136f3e2a547d09b60a3ce1ef598b1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bl=C3=A9ron?= Date: Sun, 10 Sep 2023 20:08:12 +0200 Subject: [PATCH] sync: add `?Sized` bound to `{MutexGuard,OwnedMutexGuard}::map` (#5997) --- tokio/src/sync/mutex.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokio/src/sync/mutex.rs b/tokio/src/sync/mutex.rs index 0700c260eb2..1d44e938bf5 100644 --- a/tokio/src/sync/mutex.rs +++ b/tokio/src/sync/mutex.rs @@ -846,6 +846,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { #[inline] pub fn map(mut this: Self, f: F) -> MappedMutexGuard<'a, U> where + U: ?Sized, F: FnOnce(&mut T) -> &mut U, { let data = f(&mut *this) as *mut U; @@ -894,6 +895,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> { #[inline] pub fn try_map(mut this: Self, f: F) -> Result, Self> where + U: ?Sized, F: FnOnce(&mut T) -> Option<&mut U>, { let data = match f(&mut *this) { @@ -1026,6 +1028,7 @@ impl OwnedMutexGuard { #[inline] pub fn map(mut this: Self, f: F) -> OwnedMappedMutexGuard where + U: ?Sized, F: FnOnce(&mut T) -> &mut U, { let data = f(&mut *this) as *mut U; @@ -1074,6 +1077,7 @@ impl OwnedMutexGuard { #[inline] pub fn try_map(mut this: Self, f: F) -> Result, Self> where + U: ?Sized, F: FnOnce(&mut T) -> Option<&mut U>, { let data = match f(&mut *this) {