[][src]Struct grin_util::OneTime

pub struct OneTime<T> { /* fields omitted */ }

Encapsulation of a RwLock<Option> for one-time initialization. This implementation will purposefully fail hard if not used properly, for example if not initialized before being first used (borrowed).

Implementations

impl<T> OneTime<T> where
    T: Clone
[src]

pub fn new() -> OneTime<T>[src]

Builds a new uninitialized OneTime.

pub fn init(&self, value: T)[src]

Initializes the OneTime, should only be called once after construction. Will panic (via assert) if called more than once.

pub fn borrow(&self) -> T[src]

Borrows the OneTime, should only be called after initialization. Will panic (via expect) if called before initialization.

pub fn is_init(&self) -> bool[src]

Has this OneTime been initialized?

Trait Implementations

impl<T: Clone> Clone for OneTime<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for OneTime<T>

impl<T> Send for OneTime<T> where
    T: Send + Sync

impl<T> Sync for OneTime<T> where
    T: Send + Sync

impl<T> Unpin for OneTime<T>

impl<T> !UnwindSafe for OneTime<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any