pub struct StateKey<T> { /* private fields */ }Expand description
A compile-time typed state key that eliminates typo bugs and type mismatches.
Create as a const and use with State::get_key() / State::set_key():
ⓘ
const TURN_COUNT: StateKey<u32> = StateKey::new("session:turn_count");
const SENTIMENT: StateKey<String> = StateKey::new("derived:sentiment");
state.set_key(&TURN_COUNT, 5);
let count: Option<u32> = state.get_key(&TURN_COUNT);Implementations§
Auto Trait Implementations§
impl<T> Freeze for StateKey<T>
impl<T> RefUnwindSafe for StateKey<T>
impl<T> Send for StateKey<T>
impl<T> Sync for StateKey<T>
impl<T> Unpin for StateKey<T>
impl<T> UnsafeUnpin for StateKey<T>
impl<T> UnwindSafe for StateKey<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more