-
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
Implement count
for EscapeUnicode
#33849
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Given that he has already reviewed the previous PR, maybe r? @alexcrichton |
7851c6e
to
9e228ff
Compare
Fixed rebase (which should fix the build, too) and improved stability attributes. |
Value, | ||
LeftBrace, | ||
Type, | ||
Backslash, |
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.
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
Can you also be sure to add some tests for |
☔ 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
Rebased, added a comment to explain the re-ordering (a micro-optimisation), and extended the test. |
…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.
and cleanup the code for
count
forEscapeDefault
(instead of repeating thematch
forsize_hint
andcount
).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
count
was added in #33103.