Crate take_static

Source
Expand description

This crate provides the take_static macro to create statics that provide mutable access only once:

use take_static::take_static;

take_static! {
    static NUMBER: usize = 5;
}

assert_eq!(NUMBER.take(), Some(&mut 5));
assert_eq!(NUMBER.take(), None);

The resulting statics are TakeStatic.

Macros§

take_static
Declare a new static that provides mutable access—but only once.

Structs§

TakeStatic
A synchronization primitive which can be accessed only once.