[][src]Struct conquer_once::raw::Lazy

pub struct Lazy<T, B, F = fn() -> T> { /* fields omitted */ }

A type for lazy initialization of e.g. global static variables, which provides the same functionality as the lazy_static! macro.

Implementations

impl<T, B, F> Lazy<T, B, F>[src]

pub const fn new(init: F) -> Self[src]

Creates a new uninitialized Lazy with the given init closure.

Examples

The init argument can be a simple function pointer or any FnOnce closure.

use conquer_once::Lazy;

static LAZY_1: Lazy<Vec<i32>> = Lazy::new(|| vec![1, 2, 3, 4, 5]);
static LAZY_2: Lazy<Vec<i32>> = Lazy::new(Vec::<i32>::new);

impl<T, B, F> Lazy<T, B, F> where
    B: Block,
    F: FnOnce() -> T, 
[src]

pub fn is_initialized(lazy: &Self) -> bool[src]

Returns true if the Lazy has been successfully initialized.

pub fn is_poisoned(lazy: &Self) -> bool[src]

Returns true if the Lazy has been poisoned.

pub fn get_or_init(lazy: &Self) -> &T[src]

Returns a reference to the already initialized inner value or initializes it first.

This has the same effect as using the Deref operator on a Lazy.

Panics

This method panics if the init procedure specified during construction panics or if the Lazy is poisoned.

Trait Implementations

impl<T, B, F> AsRef<T> for Lazy<T, B, F> where
    B: Block,
    F: FnOnce() -> T, 
[src]

impl<T, B, F> Borrow<T> for Lazy<T, B, F> where
    B: Block,
    F: FnOnce() -> T, 
[src]

impl<T, B, F> Debug for Lazy<T, B, F> where
    T: Debug,
    B: Block,
    F: FnOnce() -> T, 
[src]

impl<T, B, F> Deref for Lazy<T, B, F> where
    B: Block,
    F: FnOnce() -> T, 
[src]

type Target = T

The resulting type after dereferencing.

impl<T, B, F> Display for Lazy<T, B, F> where
    T: Display,
    B: Block,
    F: FnOnce() -> T, 
[src]

Auto Trait Implementations

impl<T, B, F = fn() -> T> !RefUnwindSafe for Lazy<T, B, F>

impl<T, B, F> Send for Lazy<T, B, F> where
    F: Send,
    T: Send

impl<T, B, F> Sync for Lazy<T, B, F> where
    F: Sync,
    T: Sync

impl<T, B, F> Unpin for Lazy<T, B, F> where
    B: Unpin,
    F: Unpin,
    T: Unpin

impl<T, B, F> UnwindSafe for Lazy<T, B, F> where
    B: UnwindSafe,
    F: UnwindSafe,
    T: UnwindSafe

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> From<T> for T[src]

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.