Struct singleton::Singleton [] [src]

pub struct Singleton<T: Send + Sync> { /* fields omitted */ }

A pointer type for holding shared global state in multi-thread environment.

Methods

impl<T: Send + Sync> Singleton<T>
[src]

[src]

Create an uninitialized singleton.

[src]

Access the singleton; initialize it with Default::default() if it is uninitialized.

[src]

Access the singleton; or return None if it is not yet uninitialized.

[src]

Access the singleton; initialize it with custom function if it is uninitialized.

[src]

Put the singleton into a finalized state, destruct the singleton value if it is initialized.

This is unsafe and only useful when the value holds other resources.

Trait Implementations

impl<T: Send + Sync> Default for Singleton<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<T: Send + Sync> Drop for Singleton<T>
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<T> Send for Singleton<T>

impl<T> Sync for Singleton<T>