pub type Tc = (bool, bool, bool); pub struct TcIter(usize); impl TcIter { pub fn new() -> TcIter { TcIter(0) } } impl Iterator for TcIter { type Item = Tc; fn next(&mut self) -> Option { let r = match self.0 { 0 => Some((false, false, false)), 1 => Some((false, false, true)), 2 => Some((false, true, false)), 3 => Some((false, true, true)), 4 => Some((true, false, false)), 5 => Some((true, false, true)), 6 => Some((true, true, false)), 7 => Some((true, true, true)), _ => None }; self.0 += 1; r } } use std::collections::HashMap; pub type Inner = HashMap; #[derive(Debug)] pub struct Table(Inner); impl Table { pub fn get(&self, tc: Tc) -> bool { *self.0.get(&tc).expect( "What you are seeing is expected to be logically impossible. You encountered a bug." ) } pub fn add_tc(&mut self, tc: Tc, val: bool) { self.0.insert(tc, val); } pub fn new() -> Table { Table(Inner::new()) } }