fn absorb_first(&mut self, op: &mut Operation<K, V, M>, other: &Self) {
        // Safety note for calls to .alias():
        //
        //   it is safe to alias this value here because if it is ever removed, one alias is always
        //   first dropped with NoDrop (in absorb_first), and _then_ the other (and only remaining)
        //   alias is dropped with DoDrop (in absorb_second). we won't drop the aliased value until
        //   _after_ absorb_second is called on this operation, so leaving an alias in the oplog is
        //   also safe.

        let hasher = other.data.hasher();
        match *op {
            Operation::Replace(ref key, ref mut value) => {
                let vs = self
                    .data
                    .entry(key.clone())
                    .or_insert_with(ValuesInner::new);

                // truncate vector
                vs.clear();

                // implicit shrink_to_fit on replace op
                // so it will switch back to inline allocation for the subsequent push.
                vs.shrink_to_fit();

                vs.push(unsafe { value.alias() }, hasher);
            }
            Operation::Clear(ref key) => {
                self.data
                    .entry(key.clone())
                    .or_insert_with(ValuesInner::new)
                    .clear();
            }
            Operation::Add(ref key, ref mut value) => {
                self.data
                    .entry(key.clone())
                    .or_insert_with(ValuesInner::new)
                    .push(unsafe { value.alias() }, hasher);
            }
            Operation::RemoveEntry(ref key) => {
                #[cfg(not(feature = "indexed"))]
                self.data.remove(key);
                #[cfg(feature = "indexed")]
                self.data.swap_remove(key);
            }
            Operation::Purge => {
                self.data.clear();
            }
            #[cfg(feature = "eviction")]
            Operation::EmptyAt(ref indices) => {
                for &index in indices.iter().rev() {
                    self.data.swap_remove_index(index);
                }
            }
            Operation::RemoveValue(ref key, ref value) => {
                if let Some(e) = self.data.get_mut(key) {
                    e.swap_remove(&value);
                }
            }
            Operation::Retain(ref key, ref mut predicate) => {
                if let Some(e) = self.data.get_mut(key) {
                    let mut first = true;
                    e.retain(move |v| {
                        let retain = predicate.eval(v, first);
                        first = false;
                        retain
                    });
                }
            }
            Operation::Fit(ref key) => match key {
                Some(ref key) => {
                    if let Some(e) = self.data.get_mut(key) {
                        e.shrink_to_fit();
                    }
                }
                None => {
                    for value_set in self.data.values_mut() {
                        value_set.shrink_to_fit();
                    }
                }
            },
            Operation::Reserve(ref key, additional) => match self.data.entry(key.clone()) {
                Entry::Occupied(mut entry) => {
                    entry.get_mut().reserve(additional, hasher);
                }
                Entry::Vacant(entry) => {
                    entry.insert(ValuesInner::with_capacity_and_hasher(additional, hasher));
                }
            },
            Operation::MarkReady => {
                self.ready = true;
            }
            Operation::SetMeta(ref m) => {
                self.meta = m.clone();
            }
        }
    }
/// Apply ops in such a way that no values are dropped, only forgotten
Apply ops in such a way that no values are dropped, only forgotten
Apply ops in such a way that no values are dropped only forgotten
fn absorb_first(&mut self, op: &mut Operation<K, V, M>, other: &Self) {
        // Safety note for calls to .alias():
        //
        //   it is safe to alias this value here because if it is ever removed, one alias is always
        //   first dropped with NoDrop (in absorb_first), and _then_ the other (and only remaining)
        //   alias is dropped with DoDrop (in absorb_second). we won't drop the aliased value until
        //   _after_ absorb_second is called on this operation, so leaving an alias in the oplog is
        //   also safe.
        let hasher = other.data.hasher();
        match *op {
            Operation::Replace(ref key, ref mut value) => {
                let vs = self
                    .data
                    .entry(key.clone())
                    .or_insert_with(ValuesInner::new);
                // truncate vector
                vs.clear();
                // implicit shrink_to_fit on replace op
                // so it will switch back to inline allocation for the subsequent push.
                vs.shrink_to_fit();
                vs.push(unsafe { value.alias() }, hasher);
            }
            Operation::Clear(ref key) => {
                self.data
                    .entry(key.clone())
                    .or_insert_with(ValuesInner::new)
                    .clear();
            }
            Operation::Add(ref key, ref mut value) => {
                self.data
                    .entry(key.clone())
                    .or_insert_with(ValuesInner::new)
                    .push(unsafe { value.alias() }, hasher);
            }
            Operation::RemoveEntry(ref key) => {
                #[cfg(not(feature = "indexed"))]
                self.data.remove(key);
                #[cfg(feature = "indexed")]
                self.data.swap_remove(key);
            }
            Operation::Purge => {
                self.data.clear();
            }
            #[cfg(feature = "eviction")]
            Operation::EmptyAt(ref indices) => {
                for &index in indices.iter().rev() {
                    self.data.swap_remove_index(index);
                }
            }
            Operation::RemoveValue(ref key, ref value) => {
                if let Some(e) = self.data.get_mut(key) {
                    e.swap_remove(&value);
                }
            }
            Operation::Retain(ref key, ref mut predicate) => {
                if let Some(e) = self.data.get_mut(key) {
                    let mut first = true;
                    e.retain(move |v| {
                        let retain = predicate.eval(v, first);
                        first = false;
                        retain
                    });
                }
            }
            Operation::Fit(ref key) => match key {
                Some(ref key) => {
                    if let Some(e) = self.data.get_mut(key) {
                        e.shrink_to_fit();
                    }
                }
                None => {
                    for value_set in self.data.values_mut() {
                        value_set.shrink_to_fit();
                    }
                }
            },
            Operation::Reserve(ref key, additional) => match self.data.entry(key.clone()) {
                Entry::Occupied(mut entry) => {
                    entry.get_mut().reserve(additional, hasher);
                }
                Entry::Vacant(entry) => {
                    entry.insert(ValuesInner::with_capacity_and_hasher(additional, hasher));
                }
            },
            Operation::MarkReady => {
                self.ready = true;
            }
            Operation::SetMeta(ref m) => {
                self.meta = m.clone();
            }
        }
    }
fn absorb_first ( & mut self , op : & mut Operation < K , V , M > , other : & Self ) { // Safety note for calls to .alias(): // //   it is safe to alias this value here because if it is ever removed, one alias is always //   first dropped with NoDrop (in absorb_first), and _then_ the other (and only remaining) //   alias is dropped with DoDrop (in absorb_second). we won't drop the aliased value until //   _after_ absorb_second is called on this operation, so leaving an alias in the oplog is //   also safe. let hasher = other . data . hasher ( ) ; match * op { Operation :: Replace ( ref key , ref mut value ) => { let vs = self . data . entry ( key . clone ( ) ) . or_insert_with ( ValuesInner :: new ) ; // truncate vector vs . clear ( ) ; // implicit shrink_to_fit on replace op // so it will switch back to inline allocation for the subsequent push. vs . shrink_to_fit ( ) ; vs . push ( unsafe { value . alias ( ) } , hasher ) ; } Operation :: Clear ( ref key ) => { self . data . entry ( key . clone ( ) ) . or_insert_with ( ValuesInner :: new ) . clear ( ) ; } Operation :: Add ( ref key , ref mut value ) => { self . data . entry ( key . clone ( ) ) . or_insert_with ( ValuesInner :: new ) . push ( unsafe { value . alias ( ) } , hasher ) ; } Operation :: RemoveEntry ( ref key ) => { # [ cfg ( not ( feature " " ) ) ] self . data . remove ( key ) ; # [ cfg ( feature " " ) ] self . data . swap_remove ( key ) ; } Operation :: Purge => { self . data . clear ( ) ; } # [ cfg ( feature " " ) ] Operation :: EmptyAt ( ref indices ) => { for & index in indices . iter ( ) . rev ( ) { self . data . swap_remove_index ( index ) ; } } Operation :: RemoveValue ( ref key , ref value ) => { if let Some ( e ) = self . data . get_mut ( key ) { e . swap_remove ( & value ) ; } } Operation :: Retain ( ref key , ref mut predicate ) => { if let Some ( e ) = self . data . get_mut ( key ) { let mut first = true ; e . retain ( move | v | { let retain = predicate . eval ( v , first ) ; first = false ; retain } ) ; } } Operation :: Fit ( ref key ) => match key { Some ( ref key ) => { if let Some ( e ) = self . data . get_mut ( key ) { e . shrink_to_fit ( ) ; } } None => { for value_set in self . data . values_mut ( ) { value_set . shrink_to_fit ( ) ; } } } , Operation :: Reserve ( ref key , additional ) => match self . data . entry ( key . clone ( ) ) { Entry :: Occupied ( mut entry ) => { entry . get_mut ( ) . reserve ( additional , hasher ) ; } Entry :: Vacant ( entry ) => { entry . insert ( ValuesInner :: with_capacity_and_hasher ( additional , hasher ) ) ; } } , Operation :: MarkReady => { self . ready = true ; } Operation :: SetMeta ( ref m ) => { self . meta = m . clone ( ) ; } } }
Apply ops in such a way that no values are dropped, only forgotten
Apply ops in such a way that no values are dropped only forgotten
&mut self
op
&mut Operation<K, V, M>
other
&Self
&mut self
op
&mut Operation<K, V, M>
other
&Self