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);

Trait Implementations

Returns the “default value” for a type. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.