Expand description
Provides an unsafe way to late-initialize static variables that will see a lot of use.
Meant as a replacement for static mut
that only allows setting once.
Usage:
static SOMETHING: LateInit<String> = LateInit::new();
unsafe { SOMETHING.init("hello world".to_owned()); }
println!("{}", SOMETHING);
Multiple-initialization causes a panic:
ⓘ
static SOMETHING: LateInit<String> = LateInit::new();
unsafe {
SOMETHING.init("something".to_owned());
SOMETHING.init("something else".to_owned());
}
Structs§
- The primary type for this crate. Initialize before use.