-
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
Impl String::into_chars #133057
base: master
Are you sure you want to change the base?
Impl String::into_chars #133057
Conversation
Failed to set assignee to
|
None => None, | ||
Some((_, ch)) => { | ||
let offset = iter.offset(); | ||
drop(self.bytes.drain(..offset)); |
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.
This reminds me of this thread that suggests a truncate_front
method on Vec
. Not sure if it's desired as a separate proposal.
match iter.next_back() { | ||
None => None, | ||
Some((idx, ch)) => { | ||
self.bytes.truncate(idx); |
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.
I don't use vec::IntoIter
as the snippet suggested at rust-lang/libs-team#268 (comment) because for next_back
, we'd be dropping elements from the back. It's possible to loop self.bytes_iter.next_back()
, but using a Vec seems a net win.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: tison <[email protected]>
r? @programmerjake @kennytm @Amanieu
This refers to rust-lang/libs-team#268
Before adding tests and creating a tracking issue, I'd like to reach a consensus on the implementation direction and two questions:
String::into_char_indices
method also?