Skip to content

Implement count for EscapeUnicode - #33849

Merged
bors merged 5 commits into
rust-lang:masterfrom
ranma42:escape-iters-count
May 28, 2016
Merged

Implement count for EscapeUnicode#33849
bors merged 5 commits into
rust-lang:masterfrom
ranma42:escape-iters-count

Conversation

@ranma42

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

r? @aturon

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

@ranma42

Copy link
Copy Markdown
ContributorAuthor

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

@ranma42

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadsrc/libcore/char.rs Outdated

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@bors

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

☔ 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
ranma42force-pushed the escape-iters-count branch from 9e228ff to 6b5e86bCompareMay 26, 2016 08:56
@ranma42

Copy link
Copy Markdown
ContributorAuthor

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

@alexcrichton

Copy link
Copy Markdown
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
@bors
bors merged commit 6b5e86b into rust-lang:masterMay 28, 2016
@ranma42
ranma42 deleted the escape-iters-count branch May 30, 2016 15:14
Sign up for freeto 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

@ranma42@rust-highfive@alexcrichton@bors@aturon