Uh oh!
There was an error while loading. Please reload this page.
Implement split_inclusive for slice and str - #67330
Conversation
rust-highfive
commented
Dec 15, 2019
(rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
commented
Dec 15, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Centril
commented
Dec 16, 2019
r? @SimonSapin |
Centril
commented
Dec 16, 2019
rust-highfive
commented
Dec 16, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
SimonSapin
commented
Dec 16, 2019
Hi @Centril. If you’d like help specifically from me feel free to mention me. If you believe highfive’s choice of reviewer is not appropriate (maybe that person is away for a couple weeks?) and need to find another reviewer please consider picking from https://github.com/rust-lang/highfive/blob/master/highfive/configs/rust-lang/rust.json. r? @sfackler |
Dylan-DPC-zz
commented
Dec 16, 2019
r? @KodrAus |
SimonSapin
commented
Dec 16, 2019
(Why reassign a third time so soon after the second one?) |
Dylan-DPC-zz
commented
Dec 16, 2019
Ah didn't see that you reassigned. |
bors
commented
Jan 6, 2020
☔ The latest upstream changes (presumably #67917) made this pull request unmergeable. Please resolve the merge conflicts. |
KodrAus
commented
Jan 11, 2020
I think this makes sense too, and is how I’d expect this to work. |
bors
commented
Jan 12, 2020
☔ The latest upstream changes (presumably #68142) made this pull request unmergeable. Please resolve the merge conflicts. |
JohnCSimon
commented
Jan 18, 2020
Ping from triage: @golddranks can you please address the merge conflict? |
JohnCSimon
commented
Jan 25, 2020
Pinging again from triage: @golddranks can you please address the merge conflict? |
golddranks
commented
Jan 25, 2020
@JohnCSimon Ah, sorry! I'll fix the merge conflict now. @KodrAus Thanks for the input. I agree. I'll change the behaviour to that and address that in docs. |
5855eb0 to
c493ab3Comparerust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
(Sorry for fixing seemingly stupid errors here, the tests/builds take super long to run locally ATM for some reason, so I'm pushing changes "opportunistically".) |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 25, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jan 26, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
hdhoang
commented
Feb 6, 2020
ping from triage @KodrAus, could you update your review? thanks |
KodrAus
commented
Feb 7, 2020
Thanks @golddranks! This looks good to me. Would you like to squash these commits down and I’ll merge in? |
Uh oh!
There was an error while loading. Please reload this page.
…at includes the matched part in the iterated substrings as a terminator.
…est reverse iteration.
80784eb to
5c9dc57CompareCentril
commented
Feb 21, 2020
👋 @KodrAus |
Dylan-DPC-zz
commented
Feb 22, 2020
@bors r=kodraus |
bors
commented
Feb 22, 2020
📌 Commit 5c9dc57 has been approved by |
bors
commented
Feb 22, 2020
bors
commented
Feb 22, 2020
☀️ Test successful - checks-azure |
Overview
split_inclusiveforsliceandstrandsplit_inclusive_mutforslicesplit_inclusiveis a substring/subslice splitting iterator that includes the matched part in the iterated substrings as a terminator.split_terminatorfunction. I updated the examples below.Justification for the API
splitAPI: it's easy to get the behaviour ofsplitby mapping a subslicing operation that drops the terminator. On the other hand it's impossible to derive this behaviour fromsplitwithout using hacky and brittleunsafecode. The normal way to achieve this functionality would be implementing the iterator yourself.split_at_mut. This API provides an ergonomic alternative that plays to the strengths of the iterating capabilities of Rust. (Usingsplit_at_mutiteratively used to be a real pain before NLL, fortunately the situation is a bit better now.)Discussion items
Does it make sense to mimicsplit_terminatorin that the final empty slice would be left off in case of the string/slice ending with a terminator? It might do, as this use case is naturally geared towards considering the matching part as a terminator instead of a separator.split_terminator.split_inclusive_mutfor&mut str?