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
I had a small feature proposition for the split_str function.
I had a usecase where I wanted to split on two different strings, but it only accepts a single str.
I was able to work around it because I wanted to split on \n and \r\n, so I decided to split on \n and trimmed the end \r but it would not be possible in most other cases.
The api could look like:
let x:Vec<&[u8]> = b"Mary had a little lamb".split_str_many([" ","a"]).collect();assert_eq!(x, vec![B("M"), B("ry"), B("h"), B("d"), B(""), B("little"), B("l"), B("mb"),
]);
The order of the needles would be relevant here, so if the input was ["bl","l"], it would split table like ["ta","e"].
The haystack algo can still be used, but it would only be able to advance by the length of the smallest needle (unless match is found).
The text was updated successfully, but these errors were encountered:
I don't think I want to (currently, at least) support multi-substring stuff in bstr. For that, I'd rather you use the aho-corasick or regex crates. (The former doesn't have split APIs, but I think I'd be open to adding them. PRs are welcome. You can base it off the Split iterator in regex.)
Basically, if this API were added, it would require bringing aho-corasick in as a dependency anyway. We could make it optional, but it just seems like a lot of ceremony that would be better served by just using aho-corasick directly.
Hello! Love the library, thanks a lot for it
I had a small feature proposition for the
split_str
function.I had a usecase where I wanted to split on two different strings, but it only accepts a single
str
.I was able to work around it because I wanted to split on
\n
and\r\n
, so I decided to split on\n
and trimmed the end\r
but it would not be possible in most other cases.The api could look like:
The order of the needles would be relevant here, so if the input was
["bl","l"]
, it would splittable
like["ta","e"]
.The haystack algo can still be used, but it would only be able to advance by the length of the smallest needle (unless match is found).
The text was updated successfully, but these errors were encountered: