@@ -47,10 +47,17 @@ const MAXIMUM_ZST_CAPACITY: usize = 1 << (64 - 1); // Largest possible power of
47
47
/// push onto the back in this manner, and iterating over `VecDeque` goes front
48
48
/// to back.
49
49
///
50
+ /// Since `VecDeque` is a ring buffer, its elements are not necessarily contiguous
51
+ /// in memory. If you want to access the elements as a single slice, such as for
52
+ /// efficient sorting, you can use [`make_contiguous`]. It rotates the `VecDeque`
53
+ /// so that its elements do not wrap, and returns a mutable slice to the
54
+ /// now-contiguous element sequence.
55
+ ///
50
56
/// [`push_back`]: #method.push_back
51
57
/// [`pop_front`]: #method.pop_front
52
58
/// [`extend`]: #method.extend
53
59
/// [`append`]: #method.append
60
+ /// [`make_contiguous`]: #method.make_contiguous
54
61
#[ cfg_attr( not( test) , rustc_diagnostic_item = "vecdeque_type" ) ]
55
62
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
56
63
pub struct VecDeque < T > {
@@ -2188,8 +2195,6 @@ impl<T> VecDeque<T> {
2188
2195
/// Sorting the content of a deque.
2189
2196
///
2190
2197
/// ```
2191
- /// #![feature(deque_make_contiguous)]
2192
- ///
2193
2198
/// use std::collections::VecDeque;
2194
2199
///
2195
2200
/// let mut buf = VecDeque::with_capacity(15);
@@ -2210,8 +2215,6 @@ impl<T> VecDeque<T> {
2210
2215
/// Getting immutable access to the contiguous slice.
2211
2216
///
2212
2217
/// ```rust
2213
- /// #![feature(deque_make_contiguous)]
2214
- ///
2215
2218
/// use std::collections::VecDeque;
2216
2219
///
2217
2220
/// let mut buf = VecDeque::new();
@@ -2228,7 +2231,7 @@ impl<T> VecDeque<T> {
2228
2231
/// assert_eq!(slice, &[3, 2, 1] as &[_]);
2229
2232
/// }
2230
2233
/// ```
2231
- #[ unstable ( feature = "deque_make_contiguous" , issue = "70929 " ) ]
2234
+ #[ stable ( feature = "deque_make_contiguous" , since = "1.48.0 " ) ]
2232
2235
pub fn make_contiguous ( & mut self ) -> & mut [ T ] {
2233
2236
if self . is_contiguous ( ) {
2234
2237
let tail = self . tail ;
0 commit comments