#[derive(Default)] pub struct ReorderedAttrs { count: usize, reorders: Vec>, } impl ReorderedAttrs { pub fn insert_attribute(&mut self, attribute: u16) { self.reorders.resize(attribute as usize + 1, None); self.reorders[attribute as usize] = Some(self.count as u16); self.count += 1; } pub fn get(&self, attribute: u16) -> Option { match self.reorders.get(attribute as usize) { Some(Some(attribute)) => Some(*attribute), _ => None, } } }