Struct reference_counted_singleton::RefCountedSingleton[][src]

pub struct RefCountedSingleton<T>(_);
Expand description

A reference-counted singleton whose protected data can be recreated as needed.

The protected data is created when RefCountedSingleton::get_or_init is called. That functions returns an RCSRef reference to the singleton.

RCSRef instances can be cloned as needed. The last RCSRef reference drops the data. Calling RefCountedSingleton::get_or_init again recreates the data.

Implementations

Return a counted reference to the protected data if such data exists, otherwise creates a new instance of the data by calling creator().

If the lock is poisoned, then this returns Err(None). If creator() returns an error err, then this returns Err(Some(err)).

Return a counted reference to the protected data if such data exists.

If such data is not instantiated, or the lock is poisoned, then this returns None.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.