You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vec::splice() should explain what happens with an empty range #135369
As explained in this SO answer, which I assume to be correct, using Vec::splice() with an empty range like 3..3 and a non-empty replace_with argument allows inserting multiple values at once at the index specified by, I think, the range start. But this is not documented, and I don't think it's necessarily trivial for everyone (I had to lookup that SO answer to confirm). I think an example of inserting multiple values without removing any would be beneficial for understanding that splice() is the right tool for that job (and you don't need anything more complicated via iterators and loops or whatnot, like others on SO suggested).
I added an example to the Vec::splice docs in this commit. @rustbot claim
I'm not very experienced with Rust contributions, so should I just make a PR now?
Activity
cod10129 commentedon Jan 11, 2025
I added an example to the
Vec::splicedocs in this commit.@rustbot claim
I'm not very experienced with Rust contributions, so should I just make a PR now?
the8472 commentedon Jan 11, 2025
Yes, documentation changes that do not introduce new API guarantees don't require more than a PR.
Rollup merge of rust-lang#135381 - cod10129:vec-splice-doc, r=tgross35
Unrolled build for rust-lang#135381
Rollup merge of rust-lang#135381 - cod10129:vec-splice-doc, r=tgross35