Rust typemaps with additional trait restrictions and implementations
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trivernis 06121f8234
Add map that provides a PartialEq implementation
Signed-off-by: trivernis <trivernis@protonmail.com>
3 years ago
src Add map that provides a PartialEq implementation 3 years ago
.gitignore Add initial map implementations 3 years ago
Cargo.toml Add initial map implementations 3 years ago
LICENSE Create LICENSE 3 years ago
README.md Add map that provides a PartialEq implementation 3 years ago

README.md

Trait bound Typemap

This crate offers typemaps that restrict a given type in their trait and therefore offer additional trait implementations such as Clone and PartialEq.

Usage

use trait_bound_typemap::{CloneTypeMap, TypeMapTrait, TypeMapKey};

#[derive(Clone)]
pub struct MyStruct {
    a: u8,
    b: String,
}

pub struct MyStructKey;

impl TypeMapKey for MyStructKey {
    type Value = MyStruct;
}

fn main() {
    let mut map = CloneTypeMap::new();
    let value = MyStruct {a: 5, b: String::from("Hello World")};
    map.insert::<MyStructKey>(value);
    assert!(map.contains_key::<MyStructKey>());
}

License

Apache-2.0