enumoid 0.4.0

Enum Indexed Containers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::test::types::Three;
use enumoid::EnumMap;

#[test]
fn test_map() {
  let mut map = EnumMap::<Three, u16>::new();
  assert_eq!(*map.get(Three::B), 0);
  map[Three::B] = 200;
  assert_eq!(*map.get(Three::B), 200);
  *map.get_mut(Three::C) += 1;
  assert_eq!(*map.get(Three::C), 1);
  let collected: Vec<_> = map.iter().collect();
  assert_eq!(
    collected,
    vec![(Three::A, &0), (Three::B, &200), (Three::C, &1)]
  );
}