@@ -1971,7 +1971,28 @@ impl<T, A: Allocator> VecDeque<T, A> {
1971
1971
unsafe { self . buffer_write ( self . to_physical_idx ( len) , value) }
1972
1972
}
1973
1973
1974
- /// 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.
1974
+ /// Prepends all contents of the iterator to the front of the deque.
1975
+ /// The order of the contents is preserved.
1976
+ ///
1977
+ /// # Examples
1978
+ ///
1979
+ /// ```
1980
+ /// #![feature(deque_extend_front)]
1981
+ /// use std::collections::VecDeque;
1982
+ ///
1983
+ /// let mut deque = VecDeque::from([4, 5, 6]);
1984
+ /// deque.prepend([1, 2, 3]);
1985
+ /// assert_eq!(deque, [1, 2, 3, 4, 5, 6]);
1986
+ /// ```
1987
+ #[ unstable( feature = "deque_extend_front" , issue = "146975" ) ]
1988
+ #[ track_caller]
1989
+ pub fn prepend < I : IntoIterator < Item = T , IntoIter : DoubleEndedIterator > > ( & mut self , other : I ) {
1990
+ self . extend_front ( other. into_iter ( ) . rev ( ) )
1991
+ }
1992
+
1993
+ /// Prepends all contents of the iterator to the front of the deque,
1994
+ /// as if [`push_front`][VecDeque::push_front] was called repeatedly with
1995
+ /// the values yielded by the iterator.
1975
1996
///
1976
1997
/// # Examples
1977
1998
///
@@ -1983,7 +2004,19 @@ impl<T, A: Allocator> VecDeque<T, A> {
1983
2004
/// deque.extend_front([3, 2, 1]);
1984
2005
/// assert_eq!(deque, [1, 2, 3, 4, 5, 6]);
1985
2006
/// ```
1986
- #[ unstable( feature = "deque_extend_front" , issue = "none" ) ]
2007
+ ///
2008
+ /// This behaves like [`push_front`][VecDeque::push_front] was called repeatedly:
2009
+ ///
2010
+ /// ```
2011
+ /// use std::collections::VecDeque;
2012
+ ///
2013
+ /// let mut deque = VecDeque::from([4, 5, 6]);
2014
+ /// for v in [3, 2, 1] {
2015
+ /// deque.push_front(v);
2016
+ /// }
2017
+ /// assert_eq!(deque, [1, 2, 3, 4, 5, 6]);
2018
+ /// ```
2019
+ #[ unstable( feature = "deque_extend_front" , issue = "146975" ) ]
1987
2020
#[ track_caller]
1988
2021
pub fn extend_front < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
1989
2022
<Self as SpecExtendFront < T , I :: IntoIter > >:: spec_extend_front ( self , iter. into_iter ( ) ) ;
0 commit comments