Need help with rust-typemap?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

reem
143 Stars 29 Forks 87 Commits 11 Opened issues

Description

A typesafe store keyed by types and containing different types of values.

Services available

!
?

Need anything else?

Contributors list

# 13,097
Rust
Shell
Node.js
hyper
45 commits
# 106,101
Arduino
proof-o...
casper
SQLite
6 commits
# 83,327
Rust
Shell
jsonweb...
jwk
5 commits
# 307,942
Rust
debian
rebase
C
2 commits
# 335,232
HTML
Shell
robot-f...
pyramid
2 commits
# 124,621
emacs-l...
amazon-...
s3
Haskell
2 commits
# 42,397
Rust
hub
ripgrep
rust-la...
1 commit
# 254,505
Ember
transpi...
moonscr...
React
1 commit
# 577,270
Python
Shell
Rust
1 commit
# 328,003
C
iptable...
ipvs
Applica...
1 commit
# 13,461
Ruby
Shell
HTML
algebra...
1 commit

TypeMap

A typesafe store keyed by types and containing different types of values.

Documentation

It provides functionality similar to AnyMap, but is more flexible because it allows for key-value pairs, rather than enforcing that keys and values are the same type.

Key-value associations are defined through the

Key
trait, which uses an associated type parameter and trait coherence rules to enforce the invariants of
TypeMap
.

Example

extern crate typemap;
use typemap::{TypeMap, Key};

struct KeyType;

#[derive(Debug, PartialEq)] struct Value(i32);

impl Key for KeyType { type Value = Value; }

#[test] fn test_pairing() { let mut map = TypeMap::new(); map.insert::(Value(42)); assert_eq!(*map.get::().unwrap(), Value(42)); }

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.