#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

#1243 in Rust patterns

Download history 275/week @ 2024-01-04 366/week @ 2024-01-11 503/week @ 2024-01-18 460/week @ 2024-01-25 559/week @ 2024-02-01 578/week @ 2024-02-08 749/week @ 2024-02-15 694/week @ 2024-02-22 633/week @ 2024-02-29 554/week @ 2024-03-07 525/week @ 2024-03-14 735/week @ 2024-03-21 457/week @ 2024-03-28 1486/week @ 2024-04-04 885/week @ 2024-04-11 891/week @ 2024-04-18

3,842 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