Skip to content

Commit 61f095f

Browse files
authored
sync: add ?Sized bound to {MutexGuard,OwnedMutexGuard}::map (#5997)
1 parent 65027b6 commit 61f095f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tokio/src/sync/mutex.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
846846
#[inline]
847847
pub fn map<U, F>(mut this: Self, f: F) -> MappedMutexGuard<'a, U>
848848
where
849+
U: ?Sized,
849850
F: FnOnce(&mut T) -> &mut U,
850851
{
851852
let data = f(&mut *this) as *mut U;
@@ -894,6 +895,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
894895
#[inline]
895896
pub fn try_map<U, F>(mut this: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
896897
where
898+
U: ?Sized,
897899
F: FnOnce(&mut T) -> Option<&mut U>,
898900
{
899901
let data = match f(&mut *this) {
@@ -1026,6 +1028,7 @@ impl<T: ?Sized> OwnedMutexGuard<T> {
10261028
#[inline]
10271029
pub fn map<U, F>(mut this: Self, f: F) -> OwnedMappedMutexGuard<T, U>
10281030
where
1031+
U: ?Sized,
10291032
F: FnOnce(&mut T) -> &mut U,
10301033
{
10311034
let data = f(&mut *this) as *mut U;
@@ -1074,6 +1077,7 @@ impl<T: ?Sized> OwnedMutexGuard<T> {
10741077
#[inline]
10751078
pub fn try_map<U, F>(mut this: Self, f: F) -> Result<OwnedMappedMutexGuard<T, U>, Self>
10761079
where
1080+
U: ?Sized,
10771081
F: FnOnce(&mut T) -> Option<&mut U>,
10781082
{
10791083
let data = match f(&mut *this) {

0 commit comments

Comments
 (0)