Update example code for Vec::splice to change the length#92071
Merged
bors merged 1 commit intorust-lang:masterfrom Dec 19, 2021
ajtribick:patch-1
Merged
Update example code for Vec::splice to change the length#92071bors merged 1 commit intorust-lang:masterfrom ajtribick:patch-1
bors merged 1 commit intorust-lang:masterfrom
ajtribick:patch-1
Conversation
Contributor
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon. Please see the contribution instructions for more information. |
Member
|
LGTM @bors r+ rollup=always |
Collaborator
|
📌 Commit 574bc67 has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 19, 2021
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - rust-lang#91984 (Remove `in_band_lifetimes` from `rustc_middle`) - rust-lang#92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - rust-lang#92042 (Enable `#[thread_local]` for all windows-msvc targets) - rust-lang#92071 (Update example code for Vec::splice to change the length) - rust-lang#92077 (rustdoc: Remove unused `collapsed` field) - rust-lang#92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current example for
Vec::spliceillustrates the replacement of a section of length 2 with a new section of length 2. This isn't a particularly interesting case for splice, and makes it look a bit like a shorthand for the kind of manipulations that could be done with a mutable slice.In order to provide a stronger example, this updates the example to use different lengths for the source and destination regions, and uses a slice from the middle of the vector to illustrate that this does not necessarily have to be at the beginning or the end.
Resolves #92067