This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 4d9bdcc
authored
Unrolled build for rust-lang#135381
Rollup merge of rust-lang#135381 - cod10129:vec-splice-doc, r=tgross35
Add an example for `Vec::splice` inserting elements without removing
This example clearly showcases how `splice` can be used to insert multiple elements efficiently at an index into a vector.
Fixes rust-lang#135369.
The added example:
> Using `splice` to insert new items into a vector efficiently at a specific position indicated by an empty range:
> ```rust
> let mut v = vec![1, 5];
> let new = [2, 3, 4];
> v.splice(1..1, new);
> assert_eq!(v, [1, 2, 3, 4, 5]);
> ```
`@rustbot` label A-docs A-collections1 file changed
+13
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3587 | 3587 | | |
3588 | 3588 | | |
3589 | 3589 | | |
3590 | | - | |
| 3590 | + | |
3591 | 3591 | | |
3592 | 3592 | | |
3593 | 3593 | | |
| |||
3613 | 3613 | | |
3614 | 3614 | | |
3615 | 3615 | | |
3616 | | - | |
3617 | | - | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
3618 | 3628 | | |
3619 | 3629 | | |
3620 | 3630 | | |
| |||
0 commit comments