1use std::ops::{Index, IndexMut};
2
3use crate::{EnumTable, Enumable};
4
5impl<K: Enumable, V: Default, const N: usize> Default for EnumTable<K, V, N> {
6 fn default() -> Self {
7 EnumTable::new_with_fn(|_| Default::default())
8 }
9}
10
11impl<K: Enumable, V, const N: usize> Index<K> for EnumTable<K, V, N> {
12 type Output = V;
13
14 fn index(&self, index: K) -> &Self::Output {
15 self.get(&index)
16 }
17}
18
19impl<K: Enumable, V, const N: usize> IndexMut<K> for EnumTable<K, V, N> {
20 fn index_mut(&mut self, index: K) -> &mut Self::Output {
21 self.get_mut(&index)
22 }
23}