Share str.splitlines and bytes.splitlines implementaion#1883
Merged
Conversation
palaviv
reviewed
Apr 29, 2020
palaviv
approved these changes
Jul 18, 2020
Contributor
palaviv
left a comment
There was a problem hiding this comment.
Let's push this in and maybe later we will remove the duplication.
8f8ad16 to
e9cae8a
Compare
youknowone
commented
Jul 18, 2020
|
|
||
| fn py_splitlines<U8, FW, W>( | ||
| &self, | ||
| bytes: impl std::iter::Iterator<Item = U8>, |
Member
Author
There was a problem hiding this comment.
Unfortunately, str::bytes() is std::iter::Itarator<Item=u8> but [u8]::iter() is std::iter::Iterator<Item=&u8>. Can I do this without CopyTo trait?
Member
There was a problem hiding this comment.
You could probably just give it a byte slice using str.as_bytes()
Member
Author
There was a problem hiding this comment.
Thanks, it works. I am still curious how to write a generic function to take T and &T when T is a Copy. it is practically same but I couldn't find an easy way with std.
e9cae8a to
dc3f59a
Compare
dc3f59a to
5cfdf1d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.