@@ -2392,26 +2392,31 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
2392
2392
self . spec_extend ( other. iter ( ) )
2393
2393
}
2394
2394
2395
- /// Copies elements from `src` range to the end of the vector.
2395
+ /// Appends elements specified by the `src` parameter to the end of the vector.
2396
+ /// The `src` parameter is of type [`RangeBounds`], which means that
2397
+ /// it can be used to specify a range of elements in the vector.
2398
+ ///
2399
+ /// [`RangeBounds`]: ../../std/ops/trait.RangeBounds.html
2396
2400
///
2397
2401
/// # Panics
2398
2402
///
2399
- /// Panics if the starting point is greater than the end point or if
2400
- /// the end point is greater than the length of the vector.
2403
+ /// Panics if the starting index is greater than the end index.
2404
+ /// Panics if the end index is greater than the length of the vector.
2401
2405
///
2402
2406
/// # Examples
2403
2407
///
2404
2408
/// ```
2405
- /// let mut vec = vec![0, 1, 2, 3, 4];
2406
- ///
2407
- /// vec.extend_from_within(2..);
2408
- /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4]);
2409
+ /// let mut characters1 = vec!['a', 'b', 'c', 'd', 'e'];
2410
+ /// characters1.extend_from_within(2..);
2411
+ /// assert_eq!(characters1, ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'e']);
2409
2412
///
2410
- /// vec.extend_from_within(..2);
2411
- /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1]);
2413
+ /// let mut characters2 = vec!['a', 'b', 'c', 'd', 'e'];
2414
+ /// characters2.extend_from_within(..2);
2415
+ /// assert_eq!(characters2, ['a', 'b', 'c', 'd', 'e', 'a', 'b']);
2412
2416
///
2413
- /// vec.extend_from_within(4..8);
2414
- /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]);
2417
+ /// let mut characters3 = vec!['a', 'b', 'c', 'd', 'e'];
2418
+ /// characters3.extend_from_within(1..3);
2419
+ /// assert_eq!(characters3, ['a', 'b', 'c', 'd', 'e', 'b', 'c']);
2415
2420
/// ```
2416
2421
#[ cfg( not( no_global_oom_handling) ) ]
2417
2422
#[ stable( feature = "vec_extend_from_within" , since = "1.53.0" ) ]
0 commit comments