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

Document the behaviour of infinite iterators on potentially-computable methods #47547

Merged
merged 4 commits into from
Feb 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use repeat instead of RangeFrom
  • Loading branch information
varkor committed Jan 21, 2018
commit f129374d11d51ca23d85bc678fbc1ed4e7082ab1
10 changes: 4 additions & 6 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
@@ -305,12 +305,10 @@
//! successfully for any infinite iterators.
//!
//! ```no_run
//! let positives = 1..;
//! let least = positives.min().unwrap(); // Oh no! An infinite loop!
//! // `positives.min` will either overflow and panic (in debug mode),
//! // or cause an infinite loop (in release mode), so we won't reach
//! // this point!
//! println!("The least positive number is {}.", least);
//! let ones = std::iter::repeat(1);
//! let least = ones.min().unwrap(); // Oh no! An infinite loop!
//! // `ones.min()` causes an infinite loop, so we won't reach this point!
//! println!("The smallest number one is {}.", least);
//! ```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block should be marked as ```no_run, otherwise I don't think the CI will accept it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, of course!

//!
//! [`take`]: trait.Iterator.html#method.take