-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
add as_str
method to more str
-iterators
#34204
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
fn as_str(&self) -> &'a str { | ||
match self.searcher { | ||
StrSearcherImpl::Empty(ref searcher) => &self.haystack[searcher.position..searcher.end], | ||
StrSearcherImpl::TwoWay(ref searcher) => &self.haystack[searcher.position..searcher.end], |
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.
Looks like this line is too long (> 100 chars) 😄
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.
fixed
Floodgates are opened I guess. grumble. |
I think that this is a breaking change due to the addition of a non-default method on |
Breaking change for nightly users, that is. |
:/ I'm not depending on this, I just noticed the discrepancy. Feel free to close this PR and request an RFC if you think this should be properly designed. An alternative would be to deprecate the
indeed |
There are forward and reverse iterators (string searchers) that are not double ended. Those correspond to two different string slices (one from the front cursor until the end, the other from the back cursor until the start) |
&self.haystack[searcher.position..searcher.end] | ||
}, | ||
StrSearcherImpl::TwoWay(ref searcher) => { | ||
&self.haystack[searcher.position..searcher.end] |
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.
For example, position and end have no relation and position > end is a legal state.
In the spirit of
Chars::as_str