pub fn drain<R>(&mut self, range: R) -> Drain<A, B>
    where
        R: RangeArgument<usize>,
    {
        let len = self.len();
        let start = range.start().unwrap_or(0);
        let end = range.end().unwrap_or(len);
        assert!(start <= end, "drain lower bound was too large");
        assert!(end <= len, "drain upper bound was too large");

        let drain_tail = Self::wrap_add(self.tail(), start);
        let drain_head = Self::wrap_add(self.tail(), end);
        let drain_len = end - start;

        unsafe { self.set_len(start) }

        Drain {
            deque: self as *mut _,
            after_tail: drain_head,
            after_len: len - end,
            iter: Iter {
                tail: drain_tail,
                len: drain_len,
                ring: self.xs.as_mut_slice(),
            },
        }
    }
/// Create a draining iterator that removes the specified range in the
/// `ArrayDeque` and yields the removed items.
///
/// Note 1: The element range is removed even if the iterator is not
/// consumed until the end.
///
/// Note 2: It is unspecified how many elements are removed from the deque,
/// if the `Drain` value is not dropped, but the borrow it holds expires
/// (eg. due to mem::forget).
///
/// # Panics
///
/// Panics if the starting point is greater than the end point or if
/// the end point is greater than the length of the deque.
///
/// # Examples
///
/// ```
/// use arraydeque::ArrayDeque;
///
/// let mut buf: ArrayDeque<[_; 3]> = ArrayDeque::new();
///
/// buf.push_back(0);
/// buf.push_back(1);
/// buf.push_back(2);
///
/// {
///     let drain = buf.drain(2..);
///     assert!(vec![2].into_iter().eq(drain));
/// }
///
/// {
///     let iter = buf.iter();
///     assert!(vec![0, 1].iter().eq(iter));
/// }
///
/// // A full range clears all contents
/// buf.drain(..);
/// assert!(buf.is_empty());
/// ```
Create a draining iterator that removes the specified range in the
`ArrayDeque` and yields the removed items.

Note 1: The element range is removed even if the iterator is not
consumed until the end.

Note 2: It is unspecified how many elements are removed from the deque,
if the `Drain` value is not dropped, but the borrow it holds expires
.
Create a draining iterator that removes the specified range in the ` ArrayDeque ` and yields the removed items . Note 1 : The element range is removed even if the iterator is not consumed until the end . Note 2 : It is unspecified how many elements are removed from the deque if the ` Drain ` value is not dropped but the borrow it holds expires .
pub fn drain<R>(&mut self, range: R) -> Drain<A, B>
    where
        R: RangeArgument<usize>,
    {
        let len = self.len();
        let start = range.start().unwrap_or(0);
        let end = range.end().unwrap_or(len);
        assert!(start <= end, "drain lower bound was too large");
        assert!(end <= len, "drain upper bound was too large");
        let drain_tail = Self::wrap_add(self.tail(), start);
        let drain_head = Self::wrap_add(self.tail(), end);
        let drain_len = end - start;
        unsafe { self.set_len(start) }
        Drain {
            deque: self as *mut _,
            after_tail: drain_head,
            after_len: len - end,
            iter: Iter {
                tail: drain_tail,
                len: drain_len,
                ring: self.xs.as_mut_slice(),
            },
        }
    }
pub fn drain < R > ( & mut self , range : R ) -> Drain < A , B > where R : RangeArgument < usize > , { let len = self . len ( ) ; let start = range . start ( ) . unwrap_or ( 0 ) ; let end = range . end ( ) . unwrap_or ( len ) ; assert ! ( start end " " ) ; assert ! ( end len " " ) ; let drain_tail = Self :: wrap_add ( self . tail ( ) , start ) ; let drain_head = Self :: wrap_add ( self . tail ( ) , end ) ; let drain_len = end - start ; unsafe { self . set_len ( start ) } Drain { deque : self as * mut _ , after_tail : drain_head , after_len : len - end , iter : Iter { tail : drain_tail , len : drain_len , ring : self . xs . as_mut_slice ( ) , } , } }
Create a draining iterator that removes the specified range in the
`ArrayDeque` and yields the removed items.
Create a draining iterator that removes the specified range in the ` ArrayDeque ` and yields the removed items .
&mut self
range
R
panics
Panics if the starting point is greater than the end point or if
the end point is greater than the length of the deque.
Panics if the starting point is greater than the end point or if the end point is greater than the length of the deque .
examples
```
use arraydeque::ArrayDeque.

let mut buf: ArrayDeque<[_; 3]> = ArrayDeque::new().







A full range clears all contents
buf.drain(..);
assert!(buf.is_empty());
```
` ` ` use arraydeque :: ArrayDeque . let mut buf : ArrayDeque< [ _ ; 3 ] > = ArrayDeque :: new () . A full range clears all contents buf . drain ( .. ) ; assert! ( buf . is_empty () ) ; ` ` `