Struct ctxmap::CtxMap [−][src]
pub struct CtxMap<S> { /* fields omitted */ }Expand description
A collection that can store references of different types and lifetimes.
Implementations
Create a new CtxMap with initial values.
Example
ctxmap::schema!(S);
ctxmap::key!(S { KEY_A: u16 = 20 });
ctxmap::key!(S { KEY_B: u8 });
let m = ctxmap::CtxMap::new();
assert_eq!(m[&KEY_A], 20);
assert_eq!(m[&KEY_B], 0);Sets a value to CtxMap only while f is being called.
Example
ctxmap::schema!(S);
ctxmap::key!(S { KEY_A: u16 = 20 });
let mut m = ctxmap::CtxMap::new();
assert_eq!(m[&KEY_A], 20);
m.with(&KEY_A, &30, |m| {
assert_eq!(m[&KEY_A], 30);
});
assert_eq!(m[&KEY_A], 20);