Skip to content
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

Merged
merged 5 commits into from
May 28, 2016
Merged

Conversation

ranma42
Copy link
Contributor

@ranma42 ranma42 commented May 24, 2016

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 #24214, split from #31049.

The test for count was added in #33103.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@ranma42
Copy link
Contributor Author

ranma42 commented May 24, 2016

Given that he has already reviewed the previous PR, maybe r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned aturon May 24, 2016
@ranma42 ranma42 force-pushed the escape-iters-count branch from 7851c6e to 9e228ff Compare May 25, 2016 07:29
@ranma42
Copy link
Contributor Author

ranma42 commented May 25, 2016

Fixed rebase (which should fix the build, too) and improved stability attributes.

Value,
LeftBrace,
Type,
Backslash,
Copy link
Member

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

@alexcrichton
Copy link
Member

Can you also be sure to add some tests for len as well?

@bors
Copy link
Contributor

bors commented May 26, 2016

☔ The latest upstream changes (presumably #33699) made this pull request unmergeable. Please resolve the merge conflicts.

ranma42 added 5 commits May 26, 2016 09:59
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.
Simply a micro-optimization to reduce code size and to open up
inlining opportunities.
to also check that it is legitimately an `ExactSizeIterator`.
@ranma42 ranma42 force-pushed the escape-iters-count branch from 9e228ff to 6b5e86b Compare May 26, 2016 08:56
@ranma42
Copy link
Contributor Author

ranma42 commented May 26, 2016

Rebased, added a comment to explain the re-ordering (a micro-optimisation), and extended the test.

@alexcrichton
Copy link
Member

@bors: r+ 6b5e86b

Thanks!

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
Rollup of 15 pull requests

- Successful merges: #33820, #33821, #33822, #33824, #33825, #33831, #33832, #33848, #33849, #33852, #33854, #33856, #33859, #33860, #33861
- Failed merges:
@bors bors merged commit 6b5e86b into rust-lang:master May 28, 2016
@ranma42 ranma42 deleted the escape-iters-count branch May 30, 2016 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants