Movatterモバイル変換


[0]ホーム

URL:


OnceState

std::sync

StructOnceState 

1.0.0 ·Source
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

1.51.0 ·Source

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:

usestd::sync::Once;staticINIT: Once = Once::new();INIT.call_once_force(|state| {assert!(!state.is_poisoned());});

Trait Implementations§

1.16.0 ·Source§

implDebug forOnceState

Source§

fnfmt(&self, f: &mutFormatter<'_>) ->Result

Formats the value using the given formatter.Read more

Auto Trait Implementations§

§

impl !Freeze forOnceState

§

impl !RefUnwindSafe forOnceState

§

implSend forOnceState

§

impl !Sync forOnceState

§

implUnpin forOnceState

§

implUnwindSafe forOnceState

Blanket Implementations§

Source§

impl<T>Any for T
where T: 'static + ?Sized,

Source§

fntype_id(&self) ->TypeId

Gets theTypeId ofself.Read more
Source§

impl<T>Borrow<T> for T
where T: ?Sized,

Source§

fnborrow(&self) ->&T

Immutably borrows from an owned value.Read more
Source§

impl<T>BorrowMut<T> for T
where T: ?Sized,

Source§

fnborrow_mut(&mut self) ->&mut T

Mutably borrows from an owned value.Read more
Source§

impl<T>From<T> for T

Source§

fnfrom(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U>Into<U> for T
where U:From<T>,

Source§

fninto(self) -> U

CallsU::from(self).

That is, this conversion is whatever the implementation ofFrom<T> for U chooses to do.

Source§

impl<T, U>TryFrom<U> for T
where U:Into<T>,

Source§

typeError =Infallible

The type returned in the event of a conversion error.
Source§

fntry_from(value: U) ->Result<T, <T asTryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U>TryInto<U> for T
where U:TryFrom<T>,

Source§

typeError = <U asTryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fntry_into(self) ->Result<U, <U asTryFrom<T>>::Error>

Performs the conversion.

[8]ページ先頭

©2009-2026 Movatter.jp