1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! # rustand
//!
//! A lightweight, Zustand-inspired state management library for Rust.
//!
//! `rustand` provides a simple, single-threaded way to manage shared state with subscription support.
//! It is designed to be lean, dependency-free, and easy to use.
//!
//! ## Core Features
//! - **Simple API**: Minimalist `get`, `set`, and `subscribe` pattern.
//! - **Infallible**: API methods don't return `Result`, making usage clean and idiomatic.
//! - **Zero Dependencies**: Core library has no external dependencies.
//!
//! ## Feature Flags
//! - `single-threaded` (default): Optimized for WASM or single-threaded environments. Uses `Rc` and `RefCell` to avoid atomic overhead.
//! - `wasm`: Alias for `single-threaded`, targeting WebAssembly environments.
//!
//! ## Quick Start
//!
//! ```rust
//! use rustand::Store;
//!
//! let store = Store::new(0);
//!
//! // Subscribe to changes
//! let _sub = store.subscribe(|v| println!("New value: {}", v));
//!
//! // Update state
//! store.set(|s| *s += 1);
//!
//! // Get state
//! assert_eq!(store.get(), 1);
//! ```
pub use ;
pub use Store;
pub use ;