Many times I've been looking for way to split a string in such a way that the delimiter is part of the result, interleaved with the slices.
For example:
let split = "Mary had a little lamb. The lamb lives at Mary's".split_with_delimiter('lamb').collect();
assert_eq!(split , ["Mary had a little ", "lamb", ". The ", "lamb", " lives at Mary's"]);
I've found split_inclusive which is not quite what I was looking for, as it has the delimiter stuck to the previous slice. However, split_inclusive has a similar justification for the inclusion in the API as split_with_delimiter has.
There are many stack overflow discussions about how to implement this in different languages and most of the time, hacky solutions. So, I am surprised that this is not already part of a standard library for string operations.
There are many possible combinations here, and unfortunately libstd instead of having optional arguments or some options struct, creates a new pair of functions (with reverse variant) for every possible tweak, so the string API is getting crowded.