fn traverse_internal<F, R>(
        cursor: &mut SliceData, 
        mut key: BuilderData, 
        mut bit_len: usize, 
        callback: &mut F
    ) -> Result<Option<R>>
    where F: FnMut(&[u8], usize, SliceData) -> Result<crate::hashmapaug::TraverseNextStep<R>> {
        let label = cursor.get_label(bit_len)?;
        let label_length = label.remaining_bits();
        match label_length.cmp(&bit_len) {
            Ordering::Less => {
                bit_len -= label_length + 1;

                let mut aug = cursor.clone();
                aug.checked_drain_reference()?;
                aug.checked_drain_reference()?;
                key.checked_append_references_and_data(&label)?;
                let to_visit = match callback(key.data(), key.length_in_bits(), aug)? {
                    TraverseNextStep::Stop => return Ok(None),
                    TraverseNextStep::End(r) => return Ok(Some(r)),
                    TraverseNextStep::VisitZero => [Some(0), None],
                    TraverseNextStep::VisitOne => [Some(1), None],
                    TraverseNextStep::VisitZeroOne => [Some(0), Some(1)],
                    TraverseNextStep::VisitOneZero => [Some(1), Some(0)],
                };
                for i in to_visit.iter().flatten() {
                    let mut key = key.clone();
                    key.append_bit_bool(*i != 0)?;
                    let child = &mut SliceData::from(cursor.reference(*i)?);
                    if let Some(r) = Self::traverse_internal(child, key, bit_len, callback)? {
                        return Ok(Some(r))
                    }
                }
            }
            Ordering::Equal => {
                key.checked_append_references_and_data(&label)?;
                if let TraverseNextStep::End(r) = callback(key.data(), key.length_in_bits(), cursor.clone())? {
                    return Ok(Some(r))
                }
            }
            _ => fail!(BlockError::InvalidData("label_length > bit_len".to_string()))
        }
        Ok(None)
    }
/// recursive traverse tree and call callback function
recursive traverse tree and call callback function
recursive traverse tree and call callback function
fn traverse_internal<F, R>(
        cursor: &mut SliceData, 
        mut key: BuilderData, 
        mut bit_len: usize, 
        callback: &mut F
    ) -> Result<Option<R>>
    where F: FnMut(&[u8], usize, SliceData) -> Result<crate::hashmapaug::TraverseNextStep<R>> {
        let label = cursor.get_label(bit_len)?;
        let label_length = label.remaining_bits();
        match label_length.cmp(&bit_len) {
            Ordering::Less => {
                bit_len -= label_length + 1;
                let mut aug = cursor.clone();
                aug.checked_drain_reference()?;
                aug.checked_drain_reference()?;
                key.checked_append_references_and_data(&label)?;
                let to_visit = match callback(key.data(), key.length_in_bits(), aug)? {
                    TraverseNextStep::Stop => return Ok(None),
                    TraverseNextStep::End(r) => return Ok(Some(r)),
                    TraverseNextStep::VisitZero => [Some(0), None],
                    TraverseNextStep::VisitOne => [Some(1), None],
                    TraverseNextStep::VisitZeroOne => [Some(0), Some(1)],
                    TraverseNextStep::VisitOneZero => [Some(1), Some(0)],
                };
                for i in to_visit.iter().flatten() {
                    let mut key = key.clone();
                    key.append_bit_bool(*i != 0)?;
                    let child = &mut SliceData::from(cursor.reference(*i)?);
                    if let Some(r) = Self::traverse_internal(child, key, bit_len, callback)? {
                        return Ok(Some(r))
                    }
                }
            }
            Ordering::Equal => {
                key.checked_append_references_and_data(&label)?;
                if let TraverseNextStep::End(r) = callback(key.data(), key.length_in_bits(), cursor.clone())? {
                    return Ok(Some(r))
                }
            }
            _ => fail!(BlockError::InvalidData("label_length > bit_len".to_string()))
        }
        Ok(None)
    }
fn traverse_internal < F , R > ( cursor : & mut SliceData , mut key : BuilderData , mut bit_len : usize , callback : & mut F ) -> Result < Option < R > > where F : FnMut ( & [ u8 ] , usize , SliceData ) -> Result < crate :: hashmapaug :: TraverseNextStep < R > > { let label = cursor . get_label ( bit_len ) ? ; let label_length = label . remaining_bits ( ) ; match label_length . cmp ( & bit_len ) { Ordering :: Less => { bit_len -= label_length + 1 ; let mut aug = cursor . clone ( ) ; aug . checked_drain_reference ( ) ? ; aug . checked_drain_reference ( ) ? ; key . checked_append_references_and_data ( & label ) ? ; let to_visit = match callback ( key . data ( ) , key . length_in_bits ( ) , aug ) ? { TraverseNextStep :: Stop => return Ok ( None ) , TraverseNextStep :: End ( r ) => return Ok ( Some ( r ) ) , TraverseNextStep :: VisitZero => [ Some ( 0 ) , None ] , TraverseNextStep :: VisitOne => [ Some ( 1 ) , None ] , TraverseNextStep :: VisitZeroOne => [ Some ( 0 ) , Some ( 1 ) ] , TraverseNextStep :: VisitOneZero => [ Some ( 1 ) , Some ( 0 ) ] , } ; for i in to_visit . iter ( ) . flatten ( ) { let mut key = key . clone ( ) ; key . append_bit_bool ( * i != 0 ) ? ; let child = & mut SliceData :: from ( cursor . reference ( * i ) ? ) ; if let Some ( r ) = Self :: traverse_internal ( child , key , bit_len , callback ) ? { return Ok ( Some ( r ) ) } } } Ordering :: Equal => { key . checked_append_references_and_data ( & label ) ? ; if let TraverseNextStep :: End ( r ) = callback ( key . data ( ) , key . length_in_bits ( ) , cursor . clone ( ) ) ? { return Ok ( Some ( r ) ) } } _ => fail ! ( BlockError InvalidData ( " " to_string ( ) ) ) } Ok ( None ) }
recursive traverse tree and call callback function
recursive traverse tree and call callback function
cursor
&mut SliceData
key
BuilderData
bit_len
usize
callback
&mut F
cursor
&mut SliceData
key
BuilderData
bit_len
usize
callback
&mut F