State
A Rust library for safe and effortless global and thread-local state management.
extern crate state;
static GLOBAL: Storage = new;
GLOBAL.set;
assert_eq!;
This library can be used to easily implement:
- Global Singletons
- Global or Local Cached Values
- Thread-Local Thunks
- Dynamic Thread-Local Data
- Typed Containers
See the documentation for more.
Usage
Include state
in your Cargo.toml
[dependencies]
:
[]
= "0.4"
Thread-local state management is not enabled by default. You can enable it
via the tls
feature:
[]
= { = "0.4", = ["tls"] }
Testing
This library is extensively tested. Tests can be found in tests/main.rs
. You
can run the tests with cargo test --all-features
.
License
State is licensed under either of the following, at your option:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)