INNER CODE UNIT · Rust

new

lunatic-solutions/lunatic · crates/hash-map-id/src/lib.rs:13

    pub fn new() -> Self {
        Self {
            id_seed: 0,
            store: HashMap::new(),
        }
    }

    pub fn add(&mut self, item: T) -> u64 {
        let id = self.id_seed;
        self.store.insert(id, item);
        self.id_seed += 1;
        id
    }

    pub fn remove(&mut self, id: u64) -> Option<T> {
        self.store.remove(&id)
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…