Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
Fix missing newlines that rustfmt removed.

fix trailing whitespace

Fix duplicate word.

Reformat panic reasons into a list

remove trailing whitespace 2 electric boogaloo
  • Loading branch information
HypheX committed Dec 3, 2024
1 parent efdd9e8 commit 771ec94
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,26 +3025,29 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
self.spec_extend(other.iter())
}

/// Copies elements from `src` range to the end of the vector.
/// Copies elements from one part of the vector to the end.
///
/// # Panics
/// `src` is the range that the elements will be copied from.
///
/// Panics if the starting point is greater than the end point or if
/// the end point is greater than the length of the vector.
/// # Panics if:
///
/// - The starting index is greater than the end index.
/// - The end index is greater than the length of the vector.
///
/// # Examples
///
/// ```
/// let mut vec = vec![0, 1, 2, 3, 4];
///
/// vec.extend_from_within(2..);
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4]);
/// let mut characters1 = vec!['a', 'b', 'c', 'd', 'e'];
/// characters1.extend_from_within(2..);
/// assert_eq!(characters1, ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'e']);
///
/// vec.extend_from_within(..2);
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1]);
/// let mut characters2 = vec!['a', 'b', 'c', 'd', 'e'];
/// characters2.extend_from_within(..2);
/// assert_eq!(characters2, ['a', 'b', 'c', 'd', 'e', 'a', 'b']);
///
/// vec.extend_from_within(4..8);
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]);
/// let mut characters3 = vec!['a', 'b', 'c', 'd', 'e'];
/// characters3.extend_from_within(1..3);
/// assert_eq!(characters3, ['a', 'b', 'c', 'd', 'e', 'b', 'c']);
/// ```
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "vec_extend_from_within", since = "1.53.0")]
Expand Down

0 comments on commit 771ec94

Please sign in to comment.