pub fn insert(
        &mut self,
        gen_index: GenerationalIndex,
        value: T,
    ) -> Option<(GenerationalIndex, T)> {
        if gen_index.index >= self.0.len() {
            for _ in self.0.len()..gen_index.index + 1 {
                self.0.push(None);
            }
        }

        let entry = &mut self.0[gen_index.index];

        let old = entry.take().map(|e| {
            (
                GenerationalIndex {
                    index: gen_index.index,
                    generation: e.generation,
                },
                e.value,
            )
        });
        *entry = Some(ArrayEntry {
            value,
            generation: gen_index.generation,
        });
        old
    }
/// Overwrites any entry with the matching index, returns both the GenerationalIndex and T that
/// were replaced, which may be a GenerationalIndex from a past generation.
Overwrites any entry with the matching index, returns both the GenerationalIndex and T that
were replaced, which may be a GenerationalIndex from a past generation.
Overwrites any entry with the matching index returns both the GenerationalIndex and T that were replaced which may be a GenerationalIndex from a past generation .
pub fn insert(
        &mut self,
        gen_index: GenerationalIndex,
        value: T,
    ) -> Option<(GenerationalIndex, T)> {
        if gen_index.index >= self.0.len() {
            for _ in self.0.len()..gen_index.index + 1 {
                self.0.push(None);
            }
        }
        let entry = &mut self.0[gen_index.index];
        let old = entry.take().map(|e| {
            (
                GenerationalIndex {
                    index: gen_index.index,
                    generation: e.generation,
                },
                e.value,
            )
        });
        *entry = Some(ArrayEntry {
            value,
            generation: gen_index.generation,
        });
        old
    }
pub fn insert ( & mut self , gen_index : GenerationalIndex , value : T , ) -> Option < ( GenerationalIndex , T ) > { if gen_index . index >= self . 0 . len ( ) { for _ in self . 0 . len ( ) .. gen_index . index + 1 { self . 0 . push ( None ) ; } } let entry = & mut self . 0 [ gen_index . index ] ; let old = entry . take ( ) . map ( | e | { ( GenerationalIndex { index : gen_index . index , generation : e . generation , } , e . value , ) } ) ; * entry = Some ( ArrayEntry { value , generation : gen_index . generation , } ) ; old }
Overwrites any entry with the matching index, returns both the GenerationalIndex and T that
were replaced, which may be a GenerationalIndex from a past generation.
Overwrites any entry with the matching index returns both the GenerationalIndex and T that were replaced which may be a GenerationalIndex from a past generation .
&mut self
gen_index
GenerationalIndex
value
T
&mut self
gen_index
GenerationalIndex
value
T