Skip to content

Commit eb9e7c3

Browse files
committed
Auto merge of rust-lang#74559 - jonhoo:stabilize-vecdeque-make_contiguous, r=dtolnay
Stabilize deque_make_contiguous Closes rust-lang#70929. /cc @Amanieu
2 parents 58d5ce4 + 8b55360 commit eb9e7c3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

library/alloc/src/collections/vec_deque.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,17 @@ const MAXIMUM_ZST_CAPACITY: usize = 1 << (64 - 1); // Largest possible power of
4747
/// push onto the back in this manner, and iterating over `VecDeque` goes front
4848
/// to back.
4949
///
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+
///
5056
/// [`push_back`]: #method.push_back
5157
/// [`pop_front`]: #method.pop_front
5258
/// [`extend`]: #method.extend
5359
/// [`append`]: #method.append
60+
/// [`make_contiguous`]: #method.make_contiguous
5461
#[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_type")]
5562
#[stable(feature = "rust1", since = "1.0.0")]
5663
pub struct VecDeque<T> {
@@ -2188,8 +2195,6 @@ impl<T> VecDeque<T> {
21882195
/// Sorting the content of a deque.
21892196
///
21902197
/// ```
2191-
/// #![feature(deque_make_contiguous)]
2192-
///
21932198
/// use std::collections::VecDeque;
21942199
///
21952200
/// let mut buf = VecDeque::with_capacity(15);
@@ -2210,8 +2215,6 @@ impl<T> VecDeque<T> {
22102215
/// Getting immutable access to the contiguous slice.
22112216
///
22122217
/// ```rust
2213-
/// #![feature(deque_make_contiguous)]
2214-
///
22152218
/// use std::collections::VecDeque;
22162219
///
22172220
/// let mut buf = VecDeque::new();
@@ -2228,7 +2231,7 @@ impl<T> VecDeque<T> {
22282231
/// assert_eq!(slice, &[3, 2, 1] as &[_]);
22292232
/// }
22302233
/// ```
2231-
#[unstable(feature = "deque_make_contiguous", issue = "70929")]
2234+
#[stable(feature = "deque_make_contiguous", since = "1.48.0")]
22322235
pub fn make_contiguous(&mut self) -> &mut [T] {
22332236
if self.is_contiguous() {
22342237
let tail = self.tail;

0 commit comments

Comments
 (0)