libcore: add str::first, str::split_first, str::last and str::split_last methods#89603
libcore: add str::first, str::split_first, str::last and str::split_last methods#89603eduardosm wants to merge 2 commits intorust-lang:masterfrom eduardosm:str-first-last
str::first, str::split_first, str::last and str::split_last methods#89603Conversation
|
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.
dtolnay
left a comment
There was a problem hiding this comment.
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 |
|
Now that we have an accepted ACP for this, maybe we can we reopen this PR? |
|
@eduardosm I tried to reopen this PR, but I cannot open it because the repository has been deleted. |
These methods are equivalent to their slice (
[T]) counterparts.If this PR is accepted, I will create a tracking issue and update the
issuevalue accordingly.