fn remove_helper(
        &mut self,
        previous_index: Option<usize>,
        index: usize,
        next_index: Option<usize>,
    ) -> OccupiedEntry<EntryData> {
        let head_index = self.head().expect("expected head index");
        let tail_index = self.tail().expect("expected tail index");
        let vacant_head = self.vacant_head();
        let removed_entry = mem::replace(
            &mut self.entries[index],
            Entry::Vacant(VacantEntry::new(vacant_head)),
        );

        self.generation = self.generation.wrapping_add(1);
        self.length -= 1;
        self.set_vacant_head(Some(index));

        if index == head_index && index == tail_index {
            self.head = None;
            self.tail = None;
        } else if index == head_index {
            self.entries[next_index.expect("expected next entry to exist")]
                .occupied_mut()
                .previous = None;
            self.head = next_index.map(|index| NonZeroUsize::new(index + 1).unwrap());
        } else if index == tail_index {
            self.entries[previous_index.expect("expected previous entry to exist")]
                .occupied_mut()
                .next = None;
            self.tail = previous_index.map(|index| NonZeroUsize::new(index + 1).unwrap());
        } else {
            self.entries[next_index.expect("expected next entry to exist")]
                .occupied_mut()
                .previous = previous_index;
            self.entries[previous_index.expect("expected previous entry to exist")]
                .occupied_mut()
                .next = next_index;
        }

        removed_entry.occupied()
    }
/// Removes and returns the entry at the given index with the entries previous and next index
/// values.
///
/// It is assumed that there is an entry at the given index.
///
/// # Panics
///
/// Panics if called when the list is empty. Behavior is undefined if provided indices do not
/// follow the expected constraints.
Removes and returns the entry at the given index with the entries previous and next index
values.

It is assumed that there is an entry at the given index.
Removes and returns the entry at the given index with the entries previous and next index values . It is assumed that there is an entry at the given index .
fn remove_helper(
        &mut self,
        previous_index: Option<usize>,
        index: usize,
        next_index: Option<usize>,
    ) -> OccupiedEntry<EntryData> {
        let head_index = self.head().expect("expected head index");
        let tail_index = self.tail().expect("expected tail index");
        let vacant_head = self.vacant_head();
        let removed_entry = mem::replace(
            &mut self.entries[index],
            Entry::Vacant(VacantEntry::new(vacant_head)),
        );
        self.generation = self.generation.wrapping_add(1);
        self.length -= 1;
        self.set_vacant_head(Some(index));
        if index == head_index && index == tail_index {
            self.head = None;
            self.tail = None;
        } else if index == head_index {
            self.entries[next_index.expect("expected next entry to exist")]
                .occupied_mut()
                .previous = None;
            self.head = next_index.map(|index| NonZeroUsize::new(index + 1).unwrap());
        } else if index == tail_index {
            self.entries[previous_index.expect("expected previous entry to exist")]
                .occupied_mut()
                .next = None;
            self.tail = previous_index.map(|index| NonZeroUsize::new(index + 1).unwrap());
        } else {
            self.entries[next_index.expect("expected next entry to exist")]
                .occupied_mut()
                .previous = previous_index;
            self.entries[previous_index.expect("expected previous entry to exist")]
                .occupied_mut()
                .next = next_index;
        }
        removed_entry.occupied()
    }
fn remove_helper ( & mut self , previous_index : Option < usize > , index : usize , next_index : Option < usize > , ) -> OccupiedEntry < EntryData > { let head_index = self . head ( ) . expect ( " " ) ; let tail_index = self . tail ( ) . expect ( " " ) ; let vacant_head = self . vacant_head ( ) ; let removed_entry = mem :: replace ( & mut self . entries [ index ] , Entry :: Vacant ( VacantEntry :: new ( vacant_head ) ) , ) ; self . generation = self . generation . wrapping_add ( 1 ) ; self . length -= 1 ; self . set_vacant_head ( Some ( index ) ) ; if index == head_index && index == tail_index { self . head = None ; self . tail = None ; } else if index == head_index { self . entries [ next_index . expect ( " " ) ] . occupied_mut ( ) . previous = None ; self . head = next_index . map ( | index | NonZeroUsize :: new ( index + 1 ) . unwrap ( ) ) ; } else if index == tail_index { self . entries [ previous_index . expect ( " " ) ] . occupied_mut ( ) . next = None ; self . tail = previous_index . map ( | index | NonZeroUsize :: new ( index + 1 ) . unwrap ( ) ) ; } else { self . entries [ next_index . expect ( " " ) ] . occupied_mut ( ) . previous = previous_index ; self . entries [ previous_index . expect ( " " ) ] . occupied_mut ( ) . next = next_index ; } removed_entry . occupied ( ) }
Removes and returns the entry at the given index with the entries previous and next index
values.
Removes and returns the entry at the given index with the entries previous and next index values .
&mut self
previous_index
Option<usize>
index
usize
next_index
Option<usize>
&mut self
previous_index
Option<usize>
index
usize
next_index
Option<usize>
panics
Panics if called when the list is empty. Behavior is undefined if provided indices do not
follow the expected constraints.
Panics if called when the list is empty . Behavior is undefined if provided indices do not follow the expected constraints .