pub struct OnceState { /* fields omitted */ }
🔬 This is a nightly-only experimental API. (once_poison
)
State yielded to call_once_force
’s closure parameter. The state can be
used to query the poison status of the Once
.
🔬 This is a nightly-only experimental API. (once_poison
)
Returns whether the associated Once
was poisoned prior to the
invocation of the closure passed to call_once_force
.
A poisoned Once
:
#![feature(once_poison)]
use std::sync::Once;
use std::thread;
static INIT: Once = Once::new();
let handle = thread::spawn(|| {
INIT.call_once(|| panic!());
});
assert!(handle.join().is_err());
INIT.call_once_force(|state| {
assert!(state.poisoned());
});
An unpoisoned Once
:
#![feature(once_poison)]
use std::sync::Once;
static INIT: Once = Once::new();
INIT.call_once_force(|state| {
assert!(!state.poisoned());
});
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static