pub fn push(&mut self, item: Item) -> Result<u16> {
        if self.len() == u16::max_value() {
            return Err(Error::CPTooLarge);
        }

        let double = item.is_double();
        let length = &mut self.length;

        let rc_item = Rc::new(item);
        let rc_item1 = Rc::clone(&rc_item);

        let by_index = &mut self.by_index;

        // check if in pool, if not insert it
        Ok(*self.by_entry.entry(rc_item).or_insert_with(move || {
            by_index.push(Some(Rc::clone(&rc_item1)));

            let prev_length = *length;
            if double {
                // long and double take an additional space
                by_index.push(None);
                *length += 2;
            } else {
                *length += 1;
            }
            prev_length
        }))
    }
/// Pushes an item on the pool.
Pushes an item on the pool.
Pushes an item on the pool .
pub fn push(&mut self, item: Item) -> Result<u16> {
        if self.len() == u16::max_value() {
            return Err(Error::CPTooLarge);
        }
        let double = item.is_double();
        let length = &mut self.length;
        let rc_item = Rc::new(item);
        let rc_item1 = Rc::clone(&rc_item);
        let by_index = &mut self.by_index;
        // check if in pool, if not insert it
        Ok(*self.by_entry.entry(rc_item).or_insert_with(move || {
            by_index.push(Some(Rc::clone(&rc_item1)));
            let prev_length = *length;
            if double {
                // long and double take an additional space
                by_index.push(None);
                *length += 2;
            } else {
                *length += 1;
            }
            prev_length
        }))
    }
pub fn push ( & mut self , item : Item ) -> Result < u16 > { if self . len ( ) == u16 :: max_value ( ) { return Err ( Error :: CPTooLarge ) ; } let double = item . is_double ( ) ; let length = & mut self . length ; let rc_item = Rc :: new ( item ) ; let rc_item1 = Rc :: clone ( & rc_item ) ; let by_index = & mut self . by_index ; // check if in pool, if not insert it Ok ( * self . by_entry . entry ( rc_item ) . or_insert_with ( move | | { by_index . push ( Some ( Rc :: clone ( & rc_item1 ) ) ) ; let prev_length = * length ; if double { // long and double take an additional space by_index . push ( None ) ; * length += 2 ; } else { * length += 1 ; } prev_length } ) ) }
Pushes an item on the pool.
Pushes an item on the pool .
&mut self
item
Item