#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

#2438 in Rust patterns

Download history 885/week @ 2024-07-19 861/week @ 2024-07-26 634/week @ 2024-08-02 646/week @ 2024-08-09 629/week @ 2024-08-16 1090/week @ 2024-08-23 738/week @ 2024-08-30 492/week @ 2024-09-06 844/week @ 2024-09-13 378/week @ 2024-09-20 966/week @ 2024-09-27 587/week @ 2024-10-04 537/week @ 2024-10-11 602/week @ 2024-10-18 647/week @ 2024-10-25 472/week @ 2024-11-01

2,375 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