pub fn is_prefix(&self, mut key: SliceData) -> Result<bool> {
        let mut bit_len = self.bit_len;
        let mut cursor = match self.data().cloned() {
            Some(root) if !key.is_empty() => SliceData::from(root),
            _ => return Ok(false)
        };
        let mut label = cursor.get_label(bit_len)?;
        loop {
            match SliceData::common_prefix(&label, &key) {
                (_, None, None) => (), // label == key
                (_, None, Some(remainder)) => key = remainder, // usual case
                (_, _, None) => return Ok(true), // key is prefix
                (_, Some(_), Some(_)) => return Ok(false)
            }
            if Self::is_leaf(&mut cursor) {
                return Ok(false)
            }
            let next_index = key.get_next_bit_int()?;
            if next_index >= cursor.remaining_references()
                || bit_len < label.remaining_bits() + 1 {
                debug_assert!(false);
                return Ok(false) // problem
            }
            cursor = SliceData::from(cursor.reference(next_index)?);
            bit_len -= label.remaining_bits() + 1;
            label = cursor.get_label(bit_len)?;
        }
    }
/// true if key is prefix of any item in PfxHashmap
true if key is prefix of any item in PfxHashmap
true if key is prefix of any item in PfxHashmap
pub fn is_prefix(&self, mut key: SliceData) -> Result<bool> {
        let mut bit_len = self.bit_len;
        let mut cursor = match self.data().cloned() {
            Some(root) if !key.is_empty() => SliceData::from(root),
            _ => return Ok(false)
        };
        let mut label = cursor.get_label(bit_len)?;
        loop {
            match SliceData::common_prefix(&label, &key) {
                (_, None, None) => (), // label == key
                (_, None, Some(remainder)) => key = remainder, // usual case
                (_, _, None) => return Ok(true), // key is prefix
                (_, Some(_), Some(_)) => return Ok(false)
            }
            if Self::is_leaf(&mut cursor) {
                return Ok(false)
            }
            let next_index = key.get_next_bit_int()?;
            if next_index >= cursor.remaining_references()
                || bit_len < label.remaining_bits() + 1 {
                debug_assert!(false);
                return Ok(false) // problem
            }
            cursor = SliceData::from(cursor.reference(next_index)?);
            bit_len -= label.remaining_bits() + 1;
            label = cursor.get_label(bit_len)?;
        }
    }
pub fn is_prefix ( & self , mut key : SliceData ) -> Result < bool > { let mut bit_len = self . bit_len ; let mut cursor = match self . data ( ) . cloned ( ) { Some ( root ) if ! key . is_empty ( ) => SliceData :: from ( root ) , _ => return Ok ( false ) } ; let mut label = cursor . get_label ( bit_len ) ? ; loop { match SliceData :: common_prefix ( & label , & key ) { ( _ , None , None ) => ( ) , // label == key ( _ , None , Some ( remainder ) ) => key = remainder , // usual case ( _ , _ , None ) => return Ok ( true ) , // key is prefix ( _ , Some ( _ ) , Some ( _ ) ) => return Ok ( false ) } if Self :: is_leaf ( & mut cursor ) { return Ok ( false ) } let next_index = key . get_next_bit_int ( ) ? ; if next_index >= cursor . remaining_references ( ) || bit_len < label . remaining_bits ( ) + 1 { debug_assert ! ( false ) ; return Ok ( false ) // problem } cursor = SliceData :: from ( cursor . reference ( next_index ) ? ) ; bit_len -= label . remaining_bits ( ) + 1 ; label = cursor . get_label ( bit_len ) ? ; } }
true if key is prefix of any item in PfxHashmap
true if key is prefix of any item in PfxHashmap
&self
key
SliceData
&self
key
SliceData