Vec::splice()
should explain what happens with an empty range #135369
Closed
Description
Location
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.splice
Summary
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).