@@ -3587,7 +3587,7 @@ impl<T, A: Allocator> Vec<T, A> {
3587
3587
/// with the given `replace_with` iterator and yields the removed items.
3588
3588
/// `replace_with` does not need to be the same length as `range`.
3589
3589
///
3590
- /// `range` is removed even if the iterator is not consumed until the end .
3590
+ /// `range` is removed even if the `Splice` iterator is not consumed before it is dropped .
3591
3591
///
3592
3592
/// It is unspecified how many elements are removed from the vector
3593
3593
/// if the `Splice` value is leaked.
@@ -3613,8 +3613,18 @@ impl<T, A: Allocator> Vec<T, A> {
3613
3613
/// let mut v = vec![1, 2, 3, 4];
3614
3614
/// let new = [7, 8, 9];
3615
3615
/// let u: Vec<_> = v.splice(1..3, new).collect();
3616
- /// assert_eq!(v, &[1, 7, 8, 9, 4]);
3617
- /// assert_eq!(u, &[2, 3]);
3616
+ /// assert_eq!(v, [1, 7, 8, 9, 4]);
3617
+ /// assert_eq!(u, [2, 3]);
3618
+ /// ```
3619
+ ///
3620
+ /// Using `splice` to insert new items into a vector efficiently at a specific position
3621
+ /// indicated by an empty range:
3622
+ ///
3623
+ /// ```
3624
+ /// let mut v = vec![1, 5];
3625
+ /// let new = [2, 3, 4];
3626
+ /// v.splice(1..1, new);
3627
+ /// assert_eq!(v, [1, 2, 3, 4, 5]);
3618
3628
/// ```
3619
3629
#[ cfg( not( no_global_oom_handling) ) ]
3620
3630
#[ inline]
0 commit comments