lock_free_static/lib.rs
1//! ## Examples
2//!
3//! ### Static variable
4//!
5//! ```
6//! # use lock_free_static::lock_free_static;
7//! #
8//! lock_free_static!{
9//! static VAR: i32 = 123;
10//! }
11//!
12//! fn main() {
13//! assert!(VAR.init());
14//! assert_eq!(*VAR.get().unwrap(), 123);
15//! }
16//! ```
17//!
18//! ### Mutable static variable
19//!
20//! ```
21//! # use lock_free_static::lock_free_static;
22//! #
23//! lock_free_static!{
24//! static mut VAR: i32 = 123;
25//! }
26//!
27//! fn main() {
28//! assert!(VAR.init());
29//!
30//! let mut guard = VAR.lock().unwrap();
31//! assert_eq!(*guard, 123);
32//! *guard = 321;
33//! drop(guard);
34//!
35//! assert_eq!(*VAR.lock().unwrap(), 321);
36//! }
37//! ```
38
39#![no_std]
40
41#[cfg(any(test, doc))]
42extern crate std;
43
44mod mutex;
45mod once_cell;
46mod once_mut;
47mod static_;
48
49pub use mutex::*;
50pub use once_cell::*;
51pub use once_mut::*;
52pub use static_::*;