Implement count for EscapeUnicode#33849
Merged
bors merged 5 commits intorust-lang:masterfrom May 28, 2016
Merged
Conversation
Contributor
|
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Contributor
Author
|
Given that he has already reviewed the previous PR, maybe r? @alexcrichton |
7851c6e to
9e228ff
Compare
Contributor
Author
|
Fixed rebase (which should fix the build, too) and improved stability attributes. |
src/libcore/char.rs
Outdated
Member
There was a problem hiding this comment.
Out of curiosity, why reorder these? The previous order makes a little more sense in my mind as we tend to read top-to-bottom
Member
|
Can you also be sure to add some tests for |
Collaborator
|
☔ The latest upstream changes (presumably #33699) made this pull request unmergeable. Please resolve the merge conflicts. |
In rust-lang#28662, `size_hint` was made exact for `EscapeUnicode` and `EscapeDefault`, but neither was marked as `ExactSizeIterator`.
Trivial implementation, as both are `ExactSizeIterator`s. Part of rust-lang#24214.
and reuse it in `size_hint`.
Simply a micro-optimization to reduce code size and to open up inlining opportunities.
to also check that it is legitimately an `ExactSizeIterator`.
9e228ff to
6b5e86b
Compare
Contributor
Author
|
Rebased, added a comment to explain the re-ordering (a micro-optimisation), and extended the test. |
Member
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 28, 2016
…richton Implement `count` for `EscapeUnicode` and cleanup the code for `count` for `EscapeDefault` (instead of repeating the `match` for `size_hint` and `count`). This PR marks EscapeUnicode and EscapeDefault as ExactSizeIterator. The constraints for the trait implementations held even before this PR, but I am not sure if this is something we want to guarantee/expose (I would love feedback on this, especially on what would be the appropriate way to handle stabilisation, if needed). Part of rust-lang#24214, split from rust-lang#31049. The test for `count` was added in rust-lang#33103.
bors
added a commit
that referenced
this pull request
May 28, 2016
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.
and cleanup the code for
countforEscapeDefault(instead of repeating thematchforsize_hintandcount).This PR marks EscapeUnicode and EscapeDefault as ExactSizeIterator. The constraints for the trait implementations held even before this PR, but I am not sure if this is something we want to guarantee/expose (I would love feedback on this, especially on what would be the appropriate way to handle stabilisation, if needed).
Part of #24214, split from #31049.
The test for
countwas added in #33103.