pub fn insert_before(&mut self, index: Index<EntryData>, value: EntryData) -> Index<EntryData> {
        let previous_index = match &mut self.entries[index.index] {
            Entry::Occupied(entry) if entry.generation == index.generation => entry.previous,
            _ => panic!("expected occupied entry with correct generation"),
        };
        let new_index = self.insert_new(value, previous_index, Some(index.index));
        let entry = self.entries[index.index].occupied_mut();
        entry.previous = Some(new_index);

        if Some(index.index) == self.head() {
            self.set_head(new_index);
        }

        if let Some(previous_index) = previous_index {
            self.entries[previous_index].occupied_mut().next = Some(new_index);
        }

        Index::new(new_index, self.generation)
    }
/// Inserts the given value before the value at the given index.
///
/// The index of the newly inserted value will be returned.
///
/// Complexity: amortized O(1)
///
/// # Panics
///
/// Panics if the index refers to an index not in the list anymore or if the index has been
/// invalidated. This is enforced because this function will consume the value to be inserted,
/// and if it cannot be inserted (due to the index not being valid), then it will be lost.
///
/// Also panics if the new capacity overflows `usize`.
///
/// # Examples
///
/// ```
/// use dlv_list::VecList;
///
/// let mut list = VecList::new();
/// list.push_front(0);
/// let index_1 = list.push_front(5);
/// list.push_front(10);
///
/// let index_2 = list.insert_before(index_1, 1000);
/// assert_eq!(list.get_previous_index(index_1), Some(index_2));
/// ```
Inserts the given value before the value at the given index.
The index of the newly inserted value will be returned.


Inserts the given value before the value at the given index . The index of the newly inserted value will be returned .
pub fn insert_before(&mut self, index: Index<EntryData>, value: EntryData) -> Index<EntryData> {
        let previous_index = match &mut self.entries[index.index] {
            Entry::Occupied(entry) if entry.generation == index.generation => entry.previous,
            _ => panic!("expected occupied entry with correct generation"),
        };
        let new_index = self.insert_new(value, previous_index, Some(index.index));
        let entry = self.entries[index.index].occupied_mut();
        entry.previous = Some(new_index);
        if Some(index.index) == self.head() {
            self.set_head(new_index);
        }
        if let Some(previous_index) = previous_index {
            self.entries[previous_index].occupied_mut().next = Some(new_index);
        }
        Index::new(new_index, self.generation)
    }
pub fn insert_before ( & mut self , index : Index < EntryData > , value : EntryData ) -> Index < EntryData > { let previous_index = match & mut self . entries [ index . index ] { Entry :: Occupied ( entry ) if entry . generation == index . generation => entry . previous , _ => panic ! ( " " ) , } ; let new_index = self . insert_new ( value , previous_index , Some ( index . index ) ) ; let entry = self . entries [ index . index ] . occupied_mut ( ) ; entry . previous = Some ( new_index ) ; if Some ( index . index ) == self . head ( ) { self . set_head ( new_index ) ; } if let Some ( previous_index ) = previous_index { self . entries [ previous_index ] . occupied_mut ( ) . next = Some ( new_index ) ; } Index :: new ( new_index , self . generation ) }
Inserts the given value before the value at the given index.
Inserts the given value before the value at the given index .
&mut self
index
Index<EntryData>
value
EntryData
&mut self
index
Index<EntryData>
value
EntryData
panics
Panics if the index refers to an index not in the list anymore or if the index has been
invalidated. This is enforced because this function will consume the value to be inserted,
and if it cannot be inserted (due to the index not being valid), then it will be lost.

Also panics if the new capacity overflows `usize`.
Panics if the index refers to an index not in the list anymore or if the index has been invalidated . This is enforced because this function will consume the value to be inserted and if it cannot be inserted ( due to the index not being valid ) then it will be lost . Also panics if the new capacity overflows ` usize ` .
examples
```
use dlv_list::VecList.



let index_2 = list.insert_before(index_1, 1000);
assert_eq!(list.get_previous_index(index_1), Some(index_2));
```
` ` ` use dlv_list :: VecList . let index_2 = list . insert_before ( index_1 1000 ) ; assert_eq! ( list . get_previous_index ( index_1 ) Some ( index_2 )) ; ` ` `