|
1 năm trước cách đây | |
---|---|---|
.. | ||
src | 1 năm trước cách đây | |
Cargo.toml | 1 năm trước cách đây | |
README.md | 1 năm trước cách đây |
Generational Box is a runtime for Rust that allows any static type to implement Copy
. It can be combined with a global runtime to create an ergonomic state solution like dioxus-signals
. This crate contains no unsafe
code.
Three main types manage state in Generational Box:
Example:
// Create a store for this thread
let store = Store::default();
{
// Create an owner for some state for a scope
let owner = store.owner();
// Create some non-copy data, move it into a owner, and work with copy data
let data: String = "hello world".to_string();
let key = owner.insert(data);
// The generational box can be read from and written to like a RefCell
let value = key.read();
assert_eq!(*value, "hello world");
}
// Reading value at this point will cause a panic
Internally