@@ -1983,7 +1983,28 @@ impl<T, A: Allocator> VecDeque<T, A> {
1983
1983
unsafe { self . buffer_write ( self . to_physical_idx ( len) , value) }
1984
1984
}
1985
1985
1986
- /// Prepends all elements from the iterator to the front of the deque, as if [`push_front`][VecDeque::push_front] was called with the elements of the iterator.
1986
+ /// Prepends all contents of the iterator to the front of the deque.
1987
+ /// The order of the contents is preserved.
1988
+ ///
1989
+ /// # Examples
1990
+ ///
1991
+ /// ```
1992
+ /// #![feature(deque_extend_front)]
1993
+ /// use std::collections::VecDeque;
1994
+ ///
1995
+ /// let mut deque = VecDeque::from([4, 5, 6]);
1996
+ /// deque.prepend([1, 2, 3]);
1997
+ /// assert_eq!(deque, [1, 2, 3, 4, 5, 6]);
1998
+ /// ```
1999
+ #[ unstable( feature = "deque_extend_front" , issue = "146975" ) ]
2000
+ #[ track_caller]
2001
+ pub fn prepend < I : IntoIterator < Item = T , IntoIter : DoubleEndedIterator > > ( & mut self , other : I ) {
2002
+ self . extend_front ( other. into_iter ( ) . rev ( ) )
2003
+ }
2004
+
2005
+ /// Prepends all contents of the iterator to the front of the deque,
2006
+ /// as if [`push_front`][VecDeque::push_front] was called repeatedly with
2007
+ /// the values yielded by the iterator.
1987
2008
///
1988
2009
/// # Examples
1989
2010
///
@@ -1995,7 +2016,19 @@ impl<T, A: Allocator> VecDeque<T, A> {
1995
2016
/// deque.extend_front([3, 2, 1]);
1996
2017
/// assert_eq!(deque, [1, 2, 3, 4, 5, 6]);
1997
2018
/// ```
1998
- #[ unstable( feature = "deque_extend_front" , issue = "none" ) ]
2019
+ ///
2020
+ /// This behaves like [`push_front`][VecDeque::push_front] was called repeatedly:
2021
+ ///
2022
+ /// ```
2023
+ /// use std::collections::VecDeque;
2024
+ ///
2025
+ /// let mut deque = VecDeque::from([4, 5, 6]);
2026
+ /// for v in [3, 2, 1] {
2027
+ /// deque.push_front(v);
2028
+ /// }
2029
+ /// assert_eq!(deque, [1, 2, 3, 4, 5, 6]);
2030
+ /// ```
2031
+ #[ unstable( feature = "deque_extend_front" , issue = "146975" ) ]
1999
2032
#[ track_caller]
2000
2033
pub fn extend_front < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
2001
2034
<Self as SpecExtendFront < T , I :: IntoIter > >:: spec_extend_front ( self , iter. into_iter ( ) ) ;
0 commit comments