Skip to content

Container structures for Rust that generate key upon insertion that only works with the map that generated it.

License

Notifications You must be signed in to change notification settings

MrLarssonJr/provenance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Provenance

A Rust library that provides containers that upon insertion generate a key. This key will only work with the map that generated it.

Using the library

Add the following to your Cargo.toml:

[dependencies]
provenance = "0.1.0"

Example

use provenance::ProvenanceMap;

fn main() {
    let ages = ProvenanceMap::<u32>::new().unwrap();
    let names = ProvenanceMap::<String>::new().unwrap();
    
    let middle_age: Key<u32> = ages.insert(40); // Key generated on insert
    assert_eq!(&40, ages.get(middle_age)); // Key is used to retrieve stored value
    
    // names.get(middle_age); // Compile error, key can only be used with it's map
}

About

Container structures for Rust that generate key upon insertion that only works with the map that generated it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages