+ !Sync` as `Send + Sync`
pub struct SendToSync<T> {
value: T,
}
/// # Safety
/// This is safe because wrapper never gives access to `&T` from `&self`.
/// This is essentially `Mutex::get_mut` without paying for the mutex.
unsafe impl<T> Sync for SendToSync<T> where T: Send {}
impl<T> SendToSync<T> {
pub fn new(value: T) -> Self {
SendToSync { value }
}
pub fn get_mut(&mut self) -> &mut T {
&mut self.value
}
}
The precise definition is: a type T is Sync if and only if &T is Send.
но ваще вроде ок
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9258e225a3174d60b7f53c74efde716f
Обсуждают сегодня