Skip to content

Commit d6f87c0

Browse files
committed
Integrate suggestions
1 parent 771ec94 commit d6f87c0

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

library/alloc/src/vec/mod.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -3025,29 +3025,28 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
30253025
self.spec_extend(other.iter())
30263026
}
30273027

3028-
/// Copies elements from one part of the vector to the end.
3028+
/// Given a range `src`, clone a slice of elements in that range and append it to the end.
3029+
/// `src` must be a range that can form a valid subslice of the `Vec`.
30293030
///
3030-
/// `src` is the range that the elements will be copied from.
3031-
///
3032-
/// # Panics if:
3031+
/// # Panics
30333032
///
3034-
/// - The starting index is greater than the end index.
3035-
/// - The end index is greater than the length of the vector.
3033+
/// Panics if starting index is greater than the end index
3034+
/// or if the index is greater than the length of the vector.
30363035
///
30373036
/// # Examples
30383037
///
30393038
/// ```
3040-
/// let mut characters1 = vec!['a', 'b', 'c', 'd', 'e'];
3041-
/// characters1.extend_from_within(2..);
3042-
/// assert_eq!(characters1, ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'e']);
3039+
/// let mut characters = vec!['a', 'b', 'c', 'd', 'e'];
3040+
/// characters.extend_from_within(2..);
3041+
/// assert_eq!(characters, ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'e']);
30433042
///
3044-
/// let mut characters2 = vec!['a', 'b', 'c', 'd', 'e'];
3045-
/// characters2.extend_from_within(..2);
3046-
/// assert_eq!(characters2, ['a', 'b', 'c', 'd', 'e', 'a', 'b']);
3043+
/// let mut numbers = vec![0, 1, 2, 3, 4];
3044+
/// numbers.extend_from_within(..2);
3045+
/// assert_eq!(numbers, [0, 1, 2, 3, 4, 0, 1]);
30473046
///
3048-
/// let mut characters3 = vec!['a', 'b', 'c', 'd', 'e'];
3049-
/// characters3.extend_from_within(1..3);
3050-
/// assert_eq!(characters3, ['a', 'b', 'c', 'd', 'e', 'b', 'c']);
3047+
/// let mut strings = vec![String::from("hello"), String::from("world"), String::from("!")];
3048+
/// strings.extend_from_within(1..=2);
3049+
/// assert_eq!(strings, ["hello", "world", "!", "world", "!"]);
30513050
/// ```
30523051
#[cfg(not(no_global_oom_handling))]
30533052
#[stable(feature = "vec_extend_from_within", since = "1.53.0")]

0 commit comments

Comments
 (0)