I did find that function in my investigations, but it only handles insertions into a single contiguous range in the vector. To do the equivalent of VecPatch would require several, possibly linearly many, calls to splice.
I’m not aware of any crate offering this, but I haven’t searched for it either. Possible improvements to your code:
fix the compile error of not writing mut self
only do the i <= end assertion for the largest i. Assertion failures after the first iteration of the loop can’t happen and panicking would be fatal anyways since the Vec is already in an invalid intermediate state.
Ah, both issues are a side effect of the late addition of the sort_by_key. In my application I know the inserts are already ordered so it isn't needed.
Maybe I'll make a crate for it myself then. I haven't written a utility crate like this before, seems like everything has already been done before somewhere in crates.io.