Skip to content

iterator: Add IteratorUtil::peek_ method - #7604

Merged
bors merged 1 commit into
masterfrom
unknown repository
Jul 8, 2013
Merged

bors merged 1 commit into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jul 5, 2013

Copy link
Copy Markdown

This can be useful for inserting debugging code at different steps in an iterator pipeline.

@emberian

emberian commented Jul 7, 2013

Copy link
Copy Markdown
Contributor

@apasel422 legitimate failure:

/home/rustbuild/src/rust-buildbot/slave/auto-linux-64-nopt/build/src/libstd/iterator.rs:1090:4: 1092:5 error: method `size_hint` has an incompatible type: expected uint but found enum option::Option
/home/rustbuild/src/rust-buildbot/slave/auto-linux-64-nopt/build/src/libstd/iterator.rs:1090     fn size_hint(&self) -> (Option<uint>, Option<uint>) {
/home/rustbuild/src/rust-buildbot/slave/auto-linux-64-nopt/build/src/libstd/iterator.rs:1091         self.iter.size_hint()
/home/rustbuild/src/rust-buildbot/slave/auto-linux-64-nopt/build/src/libstd/iterator.rs:1092     }
error: aborting due to previous error
make: *** [x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd.so] Error 101

The size_hint API changed, the lower bound is no longer an Option (because None is semantically equivalent to 0, for the lower bound, always)

@ghost

ghost commented Jul 8, 2013

Copy link
Copy Markdown
Author

@cmr: Fixed.

bors added a commit that referenced this pull request Jul 8, 2013
This can be useful for inserting debugging code at different steps in an iterator pipeline.
@bors bors closed this Jul 8, 2013
@bors
bors merged commit 7bb4ff6 into rust-lang:master Jul 8, 2013
@ghost
ghost deleted the peek branch July 8, 2013 19:52
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 3, 2021
Rustup

I'll write some TODOs later. This time I'll need a review for this Rustup

r? `@ghost`  (for now)

changelog: none
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
7677: More enum matching r=yoshuawuyts a=jDomantas

* Renamed existing `generate_enum_match_method` to `generate_enum_is_variant`
* Added two similar assists to generate `into_` and `as_` methods.
* Made all of them general enough to work on record and tuple variants too.

For `as_` method generation there's room to improve:
* Right now it always returns `Option<&Field>`, even though `Option<Field>` would be nicer when `Field: Copy`. I don't know how to check if the field type implements `Copy`. If given suggestions I could try to fix this in a follow-up pr.
* `&String` could be replaced with `&str`, `&Box<_>` with `&_`, and probably some more. I don't know what would be a good way to do that.

Closes rust-lang#7604

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
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.

3 participants