#map #reference #scope #lifetime

ctxmap

A collection that can store references of different types and lifetimes

1 unstable release

0.1.0 Sep 20, 2021

#878 in Data structures

32 downloads per month

MIT/Apache

11KB
199 lines

ctxmap

Crates.io Docs.rs Actions Status

A collection that can store references of different types and lifetimes.

Install

Add this to your Cargo.toml:

[dependencies]
ctxmap = "0.1.0"

Example

ctxmap::schema!(Schema);
ctxmap::key!(Schema { KEY_A: u32 = 10 });
ctxmap::key!(Schema { ref KEY_B: str = "abc" });

let mut m = ctxmap::CtxMap::new();
assert_eq!(m[&KEY_A], 10);
assert_eq!(&m[&KEY_B], "abc");

m.with(&KEY_A, &20, |m| {
    assert_eq!(m[&KEY_A], 20);
});

assert_eq!(m[&KEY_A], 10);

License

This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~345–780KB
~18K SLoC