Skip to content

Commit 07e9d11

Browse files
Address review comments
1 parent 113a869 commit 07e9d11

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

library/core/src/sync/exclusive.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use core::task::{Context, Poll};
1616
/// While this may seem not very useful, it allows `Exclusive` to _unconditionally_
1717
/// implement `Sync`. Indeed, the safety requirements of `Sync` state that for `Exclusive`
1818
/// to be `Sync`, it must be sound to _share_ across threads, that is, it must be sound
19-
/// for `&Exclusive` to cross thread boundaries. By design, a `&Exclusive` has no API
20-
/// whatsoever, making it useless, thus harmless, thus memory safe.
19+
/// for `&Exclusive` to cross thread boundaries. By design, a `&Exclusive<T>` for non-`Sync` T
20+
/// has no API whatsoever, making it useless, thus harmless, thus memory safe.
2121
///
2222
/// Certain constructs like [`Future`]s can only be used with _exclusive_ access,
2323
/// and are often `Send` but not `Sync`, so `Exclusive` can be used as hint to the
@@ -201,6 +201,17 @@ where
201201
}
202202
}
203203

204+
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
205+
impl<F, Args> Fn<Args> for Exclusive<F>
206+
where
207+
F: Sync + Fn<Args>,
208+
Args: Tuple,
209+
{
210+
extern "rust-call" fn call(&self, args: Args) -> Self::Output {
211+
self.as_mut().call(args)
212+
}
213+
}
214+
204215
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
205216
impl<T> Future for Exclusive<T>
206217
where

0 commit comments

Comments
 (0)