From cc5dbfa4012b7f9a1dbee1a74762c14f8f04c3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bl=C3=A9ron?= Date: Sun, 10 Sep 2023 17:45:08 +0200 Subject: [PATCH] Add `?Sized` bound for `MutexGuard::map` and `OwnedMutexGuard::map`. The guard structs already have `?Sized` but the function to produce them had an implicit `Sized` bound on the type parameter. --- 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) {