-
Notifications
You must be signed in to change notification settings - Fork 13.3k
libcore: add str::first
, str::split_first
, str::last
and str::split_last
methods
#89603
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
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
I would add |
I disagree. Mentally a
Yes, but there are other iterators ( |
What are "characters" in this sense? It could mean "scalar values" (i.e. the atomic unit of Unicode). Or it could mean what the user perceives as characters (e.g. extended grapheme clusters). While the standard library currently only supports the former, it's reasonable for third party crates to add support for the latter. I'm uncertain what these names should be but I think there is at least a reason to prefer unambiguous naming. I definitely support adding these functions, whatever they are named. |
To clarify: I think, that the So, maybe my first comment was a little bit to harsh. |
I like the idea of adding the |
…split_last` methods These methods are equivalent to their slice (`[T]`) counterparts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide some more detail on how you're planning to use these methods? Is there maybe an example of real-world open source code you could link to that would benefit from having these?
@eduardosm Ping from triage, any updates on this? |
I missed these methods while I was writing a lexer, although its code is not public yet. There is also #48731. |
@eduardosm |
These methods are equivalent to their slice (
[T]
) counterparts.If this PR is accepted, I will create a tracking issue and update the
issue
value accordingly.