pub fn insert(&mut self, index: usize, element: T) {
        let len = self.len();
        assert!(index <= len);

        if index == 0 {
            let head = mem::replace(&mut self.head, element);
            self.tail.insert(0, head);
        } else {
            self.tail.insert(index - 1, element);
        }
    }
/// Inserts an element at position index within the vector, shifting all elements after it to the right.
///
/// # Panics
///
/// Panics if index > len.
///
/// # Examples
///
/// ```
/// use nonempty::NonEmpty;
///
/// let mut non_empty = NonEmpty::from((1, vec![2, 3]));
/// non_empty.insert(1, 4);
/// assert_eq!(non_empty, NonEmpty::from((1, vec![4, 2, 3])));
/// non_empty.insert(4, 5);
/// assert_eq!(non_empty, NonEmpty::from((1, vec![4, 2, 3, 5])));
/// non_empty.insert(0, 42);
/// assert_eq!(non_empty, NonEmpty::from((42, vec![1, 4, 2, 3, 5])));
/// ```
Inserts an element at position index within the vector, shifting all elements after it to the right.
Inserts an element at position index within the vector shifting all elements after it to the right .
pub fn insert(&mut self, index: usize, element: T) {
        let len = self.len();
        assert!(index <= len);
        if index == 0 {
            let head = mem::replace(&mut self.head, element);
            self.tail.insert(0, head);
        } else {
            self.tail.insert(index - 1, element);
        }
    }
pub fn insert ( & mut self , index : usize , element : T ) { let len = self . len ( ) ; assert ! ( index len ) ; if index == 0 { let head = mem :: replace ( & mut self . head , element ) ; self . tail . insert ( 0 , head ) ; } else { self . tail . insert ( index - 1 , element ) ; } }
Inserts an element at position index within the vector, shifting all elements after it to the right.
Inserts an element at position index within the vector shifting all elements after it to the right .
&mut self
index
usize
element
T
&mut self
index
usize
element
T
panics
Panics if index > len.
Panics if index > len .
examples
```
use nonempty::NonEmpty.


` ` ` use nonempty :: NonEmpty .