Trait SafeSingleton

Source
pub trait SafeSingleton: Default {
    // Required methods
    fn init_instance(instance: Self);
    fn get_instance() -> LockResult<MutexGuard<'static, Self>>;
}
Expand description

Safe singleton

Singleton::init_instance - (re)initialize the singleton, prefer to use this if you want more control with the initial instance. Singleton::get_instance - get the singleton instance, if the instance is not initialized, it will initialize it with the default value.

Required Methods§

Source

fn init_instance(instance: Self)

Source

fn get_instance() -> LockResult<MutexGuard<'static, Self>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§