Trait Singleton

Source
pub trait Singleton: Default {
    // Required methods
    fn init_instance(instance: Self);
    fn get_instance() -> &'static mut Self;
}
Expand description

Unsafe 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() -> &'static mut 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§