pub struct SharedSingleton<T> { /* private fields */ }
Expand description
Single producer Single consumer Shared Singleton Note that different from RefCell, the shared singleton cannot be read until written by the producer
The inner UnsafeCell can be replaced by RefCell
Implementations§
pub const INIT_0: SharedSingleton<T>
pub const fn new() -> Self
pub fn is_vacant(&self) -> bool
Sourcepub fn try_write(&self) -> Option<&mut T>
pub fn try_write(&self) -> Option<&mut T>
Returns mutable reference of T if singleton is vacant
Sourcepub fn write_done(&self) -> Result<(), ErrCode>
pub fn write_done(&self) -> Result<(), ErrCode>
Pass ownership to Consumer from Producer
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more