pub fn remove(&mut self, key: K) -> Option<V> {
        let kd = key.data();
        if let Some(slot) = self.slots.get_mut(kd.idx as usize) {
            if slot.version() == kd.version.get() {
                self.num_elems -= 1;
                return replace(slot, Slot::new_vacant()).into_option();
            }
        }

        None
    }
/// Removes a key from the secondary map, returning the value at the key if
/// the key was not previously removed. If `key` was removed from the
/// originating slot map, its corresponding entry in the secondary map may
/// or may not already be removed.
///
/// # Examples
///
/// ```
/// # use slotmap::*;
/// let mut sm = SlotMap::new();
/// let mut squared = SecondaryMap::new();
/// let k = sm.insert(4);
/// squared.insert(k, 16);
/// squared.remove(k);
/// assert!(!squared.contains_key(k));
///
/// // It's not necessary to remove keys deleted from the primary slot map, they
/// // get deleted automatically when their slots are reused on a subsequent insert.
/// squared.insert(k, 16);
/// sm.remove(k); // Remove k from the slot map, making an empty slot.
/// let new_k = sm.insert(2); // Since sm only has one empty slot, this reuses it.
/// assert!(!squared.contains_key(new_k)); // Space reuse does not mean equal keys.
/// assert!(squared.contains_key(k)); // Slot has not been reused in squared yet.
/// squared.insert(new_k, 4);
/// assert!(!squared.contains_key(k)); // Old key is no longer available.
/// ```
Removes a key from the secondary map, returning the value at the key if
the key was not previously removed. If `key` was removed from the
originating slot map, its corresponding entry in the secondary map may
or may not already be removed.
Removes a key from the secondary map returning the value at the key if the key was not previously removed . If ` key ` was removed from the originating slot map its corresponding entry in the secondary map may or may not already be removed .
pub fn remove(&mut self, key: K) -> Option<V> {
        let kd = key.data();
        if let Some(slot) = self.slots.get_mut(kd.idx as usize) {
            if slot.version() == kd.version.get() {
                self.num_elems -= 1;
                return replace(slot, Slot::new_vacant()).into_option();
            }
        }
        None
    }
pub fn remove ( & mut self , key : K ) -> Option < V > { let kd = key . data ( ) ; if let Some ( slot ) = self . slots . get_mut ( kd . idx as usize ) { if slot . version ( ) == kd . version . get ( ) { self . num_elems -= 1 ; return replace ( slot , Slot :: new_vacant ( ) ) . into_option ( ) ; } } None }
Removes a key from the secondary map, returning the value at the key if
the key was not previously removed.
Removes a key from the secondary map returning the value at the key if the key was not previously removed .
&mut self
key
K
examples
None
use slotmap::*;
let mut sm = SlotMap::new();
let mut squared = SecondaryMap::new();
let k = sm.insert(4);
squared.insert(k, 16);
squared.remove(k);
assert!(!squared.contains_key(k)).

It's not necessary to remove keys deleted from the primary slot map, they
get deleted automatically when their slots are reused on a subsequent insert.
squared.insert(k, 16);
sm.remove(k); // Remove k from the slot map, making an empty slot.
let new_k = sm.insert(2); // Since sm only has one empty slot, this reuses it.
assert!(!squared.contains_key(new_k)); // Space reuse does not mean equal keys.
assert!(squared.contains_key(k)); // Slot has not been reused in squared yet.
squared.insert(new_k, 4);
assert!(!squared.contains_key(k)); // Old key is no longer available.
let mut sm = SlotMap :: new () ; let mut squared = SecondaryMap :: new () ; let k = sm . insert ( 4 ) ; squared . insert ( k 16 ) ; squared . remove ( k ) ; assert! ( !squared . contains_key ( k )) . It ' s not necessary to remove keys deleted from the primary slot map they get deleted automatically when their slots are reused on a subsequent insert . squared . insert ( k 16 ) ; sm . remove ( k ) ; // Remove k from the slot map making an empty slot . let new_k = sm . insert ( 2 ) ; // Since sm only has one empty slot this reuses it . assert! ( !squared . contains_key ( new_k )) ; // Space reuse does not mean equal keys . assert! ( squared . contains_key ( k )) ; // Slot has not been reused in squared yet . squared . insert ( new_k 4 ) ; assert! ( !squared . contains_key ( k )) ; // Old key is no longer available .