1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// extern crate num_traits;


#[macro_use]
pub mod vec;
pub mod id;

pub use vec::IdVec;
pub use id::Id;

#[cfg(test)]
mod examples {
    use super::*;

    #[test]
    fn example1() {
        let map = id_vec!("hello", "world");
        debug_assert!(map.contains_element(&"hello"));
    }

    #[test]
    fn example2() {
        let mut words = IdVec::new();

        let id_hello = words.insert("hello");
        let _id_world = words.insert("world");

        println!("{:?} -> {:?}", id_hello, words.get(id_hello));
        assert_eq!(words.get(id_hello), Some(&"hello"));

        words.remove(id_hello);
        assert_eq!(words.get(id_hello), None);
    }
}