pub fn remove(&mut self, key: K) -> Option<V> {
        let kd = key.data();
        if self.contains_key(key) {
            // This is safe because we know that the slot is occupied.
            Some(unsafe { self.remove_from_slot(kd.idx as usize) })
        } else {
            None
        }
    }
/// Removes a key from the slot map, returning the value at the key if the
/// key was not previously removed.
///
/// # Examples
///
/// ```
/// # use slotmap::*;
/// let mut sm = SlotMap::new();
/// let key = sm.insert(42);
/// assert_eq!(sm.remove(key), Some(42));
/// assert_eq!(sm.remove(key), None);
/// ```
Removes a key from the slot map, returning the value at the key if the
key was not previously removed.
Removes a key from the slot map returning the value at the key if the key was not previously removed .
pub fn remove(&mut self, key: K) -> Option<V> {
        let kd = key.data();
        if self.contains_key(key) {
            // This is safe because we know that the slot is occupied.
            Some(unsafe { self.remove_from_slot(kd.idx as usize) })
        } else {
            None
        }
    }
pub fn remove ( & mut self , key : K ) -> Option < V > { let kd = key . data ( ) ; if self . contains_key ( key ) { // This is safe because we know that the slot is occupied. Some ( unsafe { self . remove_from_slot ( kd . idx as usize ) } ) } else { None } }
Removes a key from the slot map, returning the value at the key if the
key was not previously removed.
Removes a key from the slot 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 key = sm.insert(42);
assert_eq!(sm.remove(key), Some(42));
assert_eq!(sm.remove(key), None);
```
let mut sm = SlotMap :: new () ; let key = sm . insert ( 42 ) ; assert_eq! ( sm . remove ( key ) Some ( 42 )) ; assert_eq! ( sm . remove ( key ) None ) ; ` ` `