-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str::split_once is underpowered #76512
Comments
Looking at your example, the type signature would be roughly fn split_once<'a>(&'a self, p: impl Pattern<'a>) -> Option<(&'a str, &'a str, &'a str)>
|
Right. I think the information already exists in the implementation as well. We only need to construct the middle between
|
There is a |
It seems somewhat similar. Curiously it also discards some information, namely the |
It's interesting that basically all string APIs are underpowered in this way? Both |
Closing this issue, we stabilized split_once with the same API shape as the rest of string methods. |
This nightly feature (#74773) makes it easy to parse key-value pairs or lists.
I could have used this method recently but required the matching character as well. Problematically it would have used a predicate pattern for finding one of several characters. To retrieve it separately is quite awkward with lots of index logic and some unwrap. Should there be a set of alternative method (or this method changed) that returns the separator as well? I'd implement that new set or change the existing methods but wanted to have some feedback on the idea first.
Rough draft of code I wanted to use:
cc: @matklad
The text was updated successfully, but these errors were encountered: