#static #once #singleton #take

no-std take-static

Static items that provide mutable access only once

3 releases

0.1.2 Aug 31, 2023
0.1.1 Aug 29, 2023
0.1.0 Aug 28, 2023

#5 in #take

Download history 1646/week @ 2024-04-07 610/week @ 2024-04-14 801/week @ 2024-04-21 469/week @ 2024-04-28 503/week @ 2024-05-05 868/week @ 2024-05-12 695/week @ 2024-05-19 583/week @ 2024-05-26 855/week @ 2024-06-02 845/week @ 2024-06-09 799/week @ 2024-06-16 510/week @ 2024-06-23 748/week @ 2024-06-30 514/week @ 2024-07-07 825/week @ 2024-07-14 875/week @ 2024-07-21

2,981 downloads per month

MIT/Apache

10KB
101 lines

take-static

Crates.io docs.rs CI

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);

For API documentation, see the docs.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~7KB