https://github.com/mkroening/take-static
Static items that provide mutable access only once.
https://github.com/mkroening/take-static
once rust singleton static sync synchronization take
Last synced: about 2 months ago
JSON representation
Static items that provide mutable access only once.
- Host: GitHub
- URL: https://github.com/mkroening/take-static
- Owner: mkroening
- License: apache-2.0
- Created: 2023-08-28T15:02:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-11T08:28:31.000Z (over 1 year ago)
- Last Synced: 2024-10-31T11:39:17.119Z (7 months ago)
- Topics: once, rust, singleton, static, sync, synchronization, take
- Language: Rust
- Homepage: https://crates.io/crates/take-static
- Size: 43 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# take-static
[](https://crates.io/crates/take-static)
[](https://docs.rs/take-static)
[](https://github.com/mkroening/take-static/actions/workflows/ci.yml)This crate provides the [`take_static`] macro to create statics that provide mutable access only once:
```rust
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].
[`take_static`]: https://docs.rs/take-static/latest/take_static/macro.take_static.html
[docs]: https://docs.rs/take-static## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)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.