Crate lateinit [−] [src]
Provides an unsafe way to late-initialize static variables that will see a lot of use.
Essentially a wrapper around UnsafeCell
that only permits setting the contained value 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
LateInit |
The primary type for this crate. Initialize before use. |