Skip to content

Commit 1f4a262

Browse files
committed
Put the docs on the methods instead of the impls
Since simulacrum suggested (on Discord) they're better there.
1 parent 2da4f9a commit 1f4a262

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

src/liballoc/collections/vec_deque.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,35 +2707,35 @@ impl<T: fmt::Debug> fmt::Debug for VecDeque<T> {
27072707
}
27082708
}
27092709

2710-
/// Turn a `Vec<T>` into a `VecDeque<T>`.
2711-
///
2712-
/// This avoids reallocating where possible, but the conditions for that are
2713-
/// strict, and subject to change, and so shouldn't be relied upon unless the
2714-
/// `Vec<T>` came from `From<VecDeque<T>>` has hasn't been reallocated.
2715-
///
2716-
/// # Examples
2717-
///
2718-
/// ```
2719-
/// use std::collections::VecDeque;
2720-
///
2721-
/// // Start with a `VecDeque<i32>`.
2722-
/// let deque: VecDeque<_> = (1..5).collect();
2723-
///
2724-
/// // Turn it into a `Vec<i32>` with no allocation needed.
2725-
/// let mut vec = Vec::from(deque);
2726-
///
2727-
/// // Modify it, being careful not to trigger reallocation.
2728-
/// vec.pop();
2729-
/// vec.push(100);
2730-
///
2731-
/// // Turn it back into a `VecDeque<i32>` with no allocation needed.
2732-
/// let ptr = vec.as_ptr();
2733-
/// let deque = VecDeque::from(vec);
2734-
/// assert_eq!(deque, [1, 2, 3, 100]);
2735-
/// assert_eq!(deque.as_slices().0.as_ptr(), ptr);
2736-
/// ```
27372710
#[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")]
27382711
impl<T> From<Vec<T>> for VecDeque<T> {
2712+
/// Turn a `Vec<T>` into a `VecDeque<T>`.
2713+
///
2714+
/// This avoids reallocating where possible, but the conditions for that are
2715+
/// strict, and subject to change, and so shouldn't be relied upon unless the
2716+
/// `Vec<T>` came from `From<VecDeque<T>>` has hasn't been reallocated.
2717+
///
2718+
/// # Examples
2719+
///
2720+
/// ```
2721+
/// use std::collections::VecDeque;
2722+
///
2723+
/// // Start with a `VecDeque<i32>`.
2724+
/// let deque: VecDeque<_> = (1..5).collect();
2725+
///
2726+
/// // Turn it into a `Vec<i32>` with no allocation needed.
2727+
/// let mut vec = Vec::from(deque);
2728+
///
2729+
/// // Modify it, being careful not to trigger reallocation.
2730+
/// vec.pop();
2731+
/// vec.push(100);
2732+
///
2733+
/// // Turn it back into a `VecDeque<i32>` with no allocation needed.
2734+
/// let ptr = vec.as_ptr();
2735+
/// let deque = VecDeque::from(vec);
2736+
/// assert_eq!(deque, [1, 2, 3, 100]);
2737+
/// assert_eq!(deque.as_slices().0.as_ptr(), ptr);
2738+
/// ```
27392739
fn from(mut other: Vec<T>) -> Self {
27402740
unsafe {
27412741
let other_buf = other.as_mut_ptr();
@@ -2760,34 +2760,34 @@ impl<T> From<Vec<T>> for VecDeque<T> {
27602760
}
27612761
}
27622762

2763-
/// Turn a `VecDeque<T>` into a `Vec<T>`.
2764-
///
2765-
/// This never needs to re-allocate, but does need to do O(n) data movement if
2766-
/// the circular buffer doesn't happen to be at the beginning of the allocation.
2767-
///
2768-
/// # Examples
2769-
///
2770-
/// ```
2771-
/// use std::collections::VecDeque;
2772-
///
2773-
/// // This one is O(1).
2774-
/// let deque: VecDeque<_> = (1..5).collect();
2775-
/// let ptr = deque.as_slices().0.as_ptr();
2776-
/// let vec = Vec::from(deque);
2777-
/// assert_eq!(vec, [1, 2, 3, 4]);
2778-
/// assert_eq!(vec.as_ptr(), ptr);
2779-
///
2780-
/// // This one needs data rearranging.
2781-
/// let mut deque: VecDeque<_> = (1..5).collect();
2782-
/// deque.push_front(9);
2783-
/// deque.push_front(8);
2784-
/// let ptr = deque.as_slices().1.as_ptr();
2785-
/// let vec = Vec::from(deque);
2786-
/// assert_eq!(vec, [8, 9, 1, 2, 3, 4]);
2787-
/// assert_eq!(vec.as_ptr(), ptr);
2788-
/// ```
27892763
#[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")]
27902764
impl<T> From<VecDeque<T>> for Vec<T> {
2765+
/// Turn a `VecDeque<T>` into a `Vec<T>`.
2766+
///
2767+
/// This never needs to re-allocate, but does need to do O(n) data movement if
2768+
/// the circular buffer doesn't happen to be at the beginning of the allocation.
2769+
///
2770+
/// # Examples
2771+
///
2772+
/// ```
2773+
/// use std::collections::VecDeque;
2774+
///
2775+
/// // This one is O(1).
2776+
/// let deque: VecDeque<_> = (1..5).collect();
2777+
/// let ptr = deque.as_slices().0.as_ptr();
2778+
/// let vec = Vec::from(deque);
2779+
/// assert_eq!(vec, [1, 2, 3, 4]);
2780+
/// assert_eq!(vec.as_ptr(), ptr);
2781+
///
2782+
/// // This one needs data rearranging.
2783+
/// let mut deque: VecDeque<_> = (1..5).collect();
2784+
/// deque.push_front(9);
2785+
/// deque.push_front(8);
2786+
/// let ptr = deque.as_slices().1.as_ptr();
2787+
/// let vec = Vec::from(deque);
2788+
/// assert_eq!(vec, [8, 9, 1, 2, 3, 4]);
2789+
/// assert_eq!(vec.as_ptr(), ptr);
2790+
/// ```
27912791
fn from(other: VecDeque<T>) -> Self {
27922792
unsafe {
27932793
let buf = other.buf.ptr();

0 commit comments

Comments
 (0)