Skip to content

Commit 771ec94

Browse files
committed
Improve documentation
Fix missing newlines that rustfmt removed. fix trailing whitespace Fix duplicate word. Reformat panic reasons into a list remove trailing whitespace 2 electric boogaloo
1 parent efdd9e8 commit 771ec94

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

library/alloc/src/vec/mod.rs

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

3028-
/// Copies elements from `src` range to the end of the vector.
3028+
/// Copies elements from one part of the vector to the end.
30293029
///
3030-
/// # Panics
3030+
/// `src` is the range that the elements will be copied from.
30313031
///
3032-
/// Panics if the starting point is greater than the end point or if
3033-
/// the end point is greater than the length of the vector.
3032+
/// # Panics if:
3033+
///
3034+
/// - The starting index is greater than the end index.
3035+
/// - The end index is greater than the length of the vector.
30343036
///
30353037
/// # Examples
30363038
///
30373039
/// ```
3038-
/// let mut vec = vec![0, 1, 2, 3, 4];
3039-
///
3040-
/// vec.extend_from_within(2..);
3041-
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4]);
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']);
30423043
///
3043-
/// vec.extend_from_within(..2);
3044-
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1]);
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']);
30453047
///
3046-
/// vec.extend_from_within(4..8);
3047-
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]);
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']);
30483051
/// ```
30493052
#[cfg(not(no_global_oom_handling))]
30503053
#[stable(feature = "vec_extend_from_within", since = "1.53.0")]

0 commit comments

Comments
 (0)