macro_rules! take_static {
    () => { ... };
    ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => { ... };
    ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => { ... };
}
Expand description

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

Syntax

The macro wraps any number of static declarations and makes them TakeStatic. Publicity and attributes for each static are allowed. Example:

use take_static::take_static;

take_static! {
    pub static FOO: u32 = 1;

    static BAR: f32 = 1.0;
}

assert_eq!(FOO.take(), Some(&mut 1));
assert_eq!(BAR.take(), Some(&mut 1.0));

See TakeStatic documentation for more information.