pub struct OnceState {/* private fields */ }Expand description
State yielded toOnce::call_once_force()’s closure parameter. The statecan be used to query the poison status of theOnce.
Implementations§
Source§implOnceState
implOnceState
1.51.0 ·Sourcepub fnis_poisoned(&self) ->bool
pub fnis_poisoned(&self) ->bool
Returnstrue if the associatedOnce was poisoned prior to theinvocation of the closure passed toOnce::call_once_force().
§Examples
A poisonedOnce:
usestd::sync::Once;usestd::thread;staticINIT: Once = Once::new();// poison the oncelethandle = thread::spawn(|| { INIT.call_once(||panic!());});assert!(handle.join().is_err());INIT.call_once_force(|state| {assert!(state.is_poisoned());});An unpoisonedOnce:
Trait Implementations§
Auto Trait Implementations§
impl !Freeze forOnceState
impl !RefUnwindSafe forOnceState
implSend forOnceState
impl !Sync forOnceState
implUnpin forOnceState
implUnwindSafe forOnceState
Blanket Implementations§
Source§impl<T>BorrowMut<T> for Twhere T: ?Sized,
impl<T>BorrowMut<T> for Twhere T: ?Sized,
Source§fnborrow_mut(&mut self) ->&mut T
fnborrow_mut(&mut self) ->&mut T
Mutably borrows from an owned value.Read more