fn put_to_fork(
        slice: &mut SliceData,
        bit_len: usize,
        mut key: SliceData,
        leaf: &BuilderData,
        extra: &Y
    ) -> AugResult<Y> {
        let next_index = key.get_next_bit_int()?;
        // ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) right:^(HashmapAug n X Y) extra:Y
        // = HashmapAugNode (n + 1) X Y;
        if slice.remaining_references() < 2 {
            fail!(
                BlockError::InvalidArg("slice must contain 2 or more references".to_string())
            )
        }
        let mut references = slice.shrink_references(2..); // left and right, drop extra
        assert_eq!(references.len(), 2);
        let mut fork_extra = Self::find_extra(&mut SliceData::from(references[1 - next_index].clone()), bit_len - 1)?;
        let (result, extra) = Self::put_to_node(&mut references[next_index], bit_len - 1, key, leaf, extra)?;
        fork_extra.calc(&extra)?;
        let mut builder = BuilderData::new();
        for reference in references.drain(..) {
            builder.checked_append_reference(reference)?;
        }
        fork_extra.write_to(&mut builder)?;
        *slice = builder.into_cell()?.into();
        Ok((result, fork_extra))
    }
// Puts element to required branch by first bit
Puts element to required branch by first bit
Puts element to required branch by first bit
fn put_to_fork(
        slice: &mut SliceData,
        bit_len: usize,
        mut key: SliceData,
        leaf: &BuilderData,
        extra: &Y
    ) -> AugResult<Y> {
        let next_index = key.get_next_bit_int()?;
        // ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) right:^(HashmapAug n X Y) extra:Y
        // = HashmapAugNode (n + 1) X Y;
        if slice.remaining_references() < 2 {
            fail!(
                BlockError::InvalidArg("slice must contain 2 or more references".to_string())
            )
        }
        let mut references = slice.shrink_references(2..); // left and right, drop extra
        assert_eq!(references.len(), 2);
        let mut fork_extra = Self::find_extra(&mut SliceData::from(references[1 - next_index].clone()), bit_len - 1)?;
        let (result, extra) = Self::put_to_node(&mut references[next_index], bit_len - 1, key, leaf, extra)?;
        fork_extra.calc(&extra)?;
        let mut builder = BuilderData::new();
        for reference in references.drain(..) {
            builder.checked_append_reference(reference)?;
        }
        fork_extra.write_to(&mut builder)?;
        *slice = builder.into_cell()?.into();
        Ok((result, fork_extra))
    }
fn put_to_fork ( slice : & mut SliceData , bit_len : usize , mut key : SliceData , leaf : & BuilderData , extra : & Y ) -> AugResult < Y > { let next_index = key . get_next_bit_int ( ) ? ; // ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) right:^(HashmapAug n X Y) extra:Y // = HashmapAugNode (n + 1) X Y; if slice . remaining_references ( ) < 2 { fail ! ( BlockError InvalidArg ( " " to_string ( ) ) ) } let mut references = slice . shrink_references ( 2 .. ) ; // left and right, drop extra assert_eq ! ( references len ( ) 2 ) ; let mut fork_extra = Self :: find_extra ( & mut SliceData :: from ( references [ 1 - next_index ] . clone ( ) ) , bit_len - 1 ) ? ; let ( result , extra ) = Self :: put_to_node ( & mut references [ next_index ] , bit_len - 1 , key , leaf , extra ) ? ; fork_extra . calc ( & extra ) ? ; let mut builder = BuilderData :: new ( ) ; for reference in references . drain ( .. ) { builder . checked_append_reference ( reference ) ? ; } fork_extra . write_to ( & mut builder ) ? ; * slice = builder . into_cell ( ) ? . into ( ) ; Ok ( ( result , fork_extra ) ) }
Puts element to required branch by first bit
Puts element to required branch by first bit
slice
&mut SliceData
bit_len
usize
key
SliceData
leaf
&BuilderData
extra
&Y
slice
&mut SliceData
bit_len
usize
key
SliceData
leaf
&BuilderData
extra
&Y