pub fn remove_raw(&mut self, key_raw: &[u8]) -> Option<Vec<u8>> {
        let index_lookup = self.raw_key_to_index_lookup(key_raw);
        match env::storage_read(&index_lookup) {
            Some(index_raw) => {
                if self.len() == 1 {
                    // If there is only one element then swap remove simply removes it without
                    // swapping with the last element.
                    env::storage_remove(&index_lookup);
                } else {
                    // If there is more than one element then swap remove swaps it with the last
                    // element.
                    let last_key_raw = match self.keys.get_raw(self.len() - 1) {
                        Some(x) => x,
                        None => env::panic(ERR_INCONSISTENT_STATE),
                    };
                    env::storage_remove(&index_lookup);
                    // If the removed element was the last element from keys, then we don't need to
                    // reinsert the lookup back.
                    if last_key_raw != key_raw {
                        let last_lookup_key = self.raw_key_to_index_lookup(&last_key_raw);
                        env::storage_write(&last_lookup_key, &index_raw);
                    }
                }
                let index = Self::deserialize_index(&index_raw);
                self.keys.swap_remove_raw(index);
                Some(self.values.swap_remove_raw(index))
            }
            None => None,
        }
    }
/// Removes a serialized key from the map, returning the serialized value at the key if the key
/// was previously in the map.
Removes a serialized key from the map, returning the serialized value at the key if the key
was previously in the map.
Removes a serialized key from the map returning the serialized value at the key if the key was previously in the map .
pub fn remove_raw(&mut self, key_raw: &[u8]) -> Option<Vec<u8>> {
        let index_lookup = self.raw_key_to_index_lookup(key_raw);
        match env::storage_read(&index_lookup) {
            Some(index_raw) => {
                if self.len() == 1 {
                    // If there is only one element then swap remove simply removes it without
                    // swapping with the last element.
                    env::storage_remove(&index_lookup);
                } else {
                    // If there is more than one element then swap remove swaps it with the last
                    // element.
                    let last_key_raw = match self.keys.get_raw(self.len() - 1) {
                        Some(x) => x,
                        None => env::panic(ERR_INCONSISTENT_STATE),
                    };
                    env::storage_remove(&index_lookup);
                    // If the removed element was the last element from keys, then we don't need to
                    // reinsert the lookup back.
                    if last_key_raw != key_raw {
                        let last_lookup_key = self.raw_key_to_index_lookup(&last_key_raw);
                        env::storage_write(&last_lookup_key, &index_raw);
                    }
                }
                let index = Self::deserialize_index(&index_raw);
                self.keys.swap_remove_raw(index);
                Some(self.values.swap_remove_raw(index))
            }
            None => None,
        }
    }
pub fn remove_raw ( & mut self , key_raw : & [ u8 ] ) -> Option < Vec < u8 > > { let index_lookup = self . raw_key_to_index_lookup ( key_raw ) ; match env :: storage_read ( & index_lookup ) { Some ( index_raw ) => { if self . len ( ) == 1 { // If there is only one element then swap remove simply removes it without // swapping with the last element. env :: storage_remove ( & index_lookup ) ; } else { // If there is more than one element then swap remove swaps it with the last // element. let last_key_raw = match self . keys . get_raw ( self . len ( ) - 1 ) { Some ( x ) => x , None => env :: panic ( ERR_INCONSISTENT_STATE ) , } ; env :: storage_remove ( & index_lookup ) ; // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if last_key_raw != key_raw { let last_lookup_key = self . raw_key_to_index_lookup ( & last_key_raw ) ; env :: storage_write ( & last_lookup_key , & index_raw ) ; } } let index = Self :: deserialize_index ( & index_raw ) ; self . keys . swap_remove_raw ( index ) ; Some ( self . values . swap_remove_raw ( index ) ) } None => None , } }
Removes a serialized key from the map, returning the serialized value at the key if the key
was previously in the map.
Removes a serialized key from the map returning the serialized value at the key if the key was previously in the map .
&mut self
key_raw
&[u8]