File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,6 @@ fn _assert_is_object_safe(_: &Iterator<Item=()>) {}
2525/// generally, please see the [module-level documentation]. In particular, you
2626/// may want to know how to [implement `Iterator`][impl].
2727///
28- /// Note: Methods on infinite iterators that generally require traversing every
29- /// element to produce a result may not terminate, even on traits for which a
30- /// result is determinable in finite time.
31- ///
3228/// [module-level documentation]: index.html
3329/// [impl]: index.html#implementing-iterator
3430#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1430,6 +1426,10 @@ pub trait Iterator {
14301426 /// Folding is useful whenever you have a collection of something, and want
14311427 /// to produce a single value from it.
14321428 ///
1429+ /// Note: `fold()`, and similar methods that traverse the entire iterator,
1430+ /// may not terminate for infinite iterators, even on traits for which a
1431+ /// result is determinable in finite time.
1432+ ///
14331433 /// # Examples
14341434 ///
14351435 /// Basic usage:
Original file line number Diff line number Diff line change 299299//! This will print the numbers `0` through `4`, each on their own line.
300300//!
301301//! Bear in mind that methods on infinite iterators, even those for which a
302- //! result can be computed in finite time, may not terminate. Specifically,
303- //! methods such as [`min`], which in the general case require traversing
304- //! every element in the iterator, are likely never to terminate for any
305- //! infinite iterators.
302+ //! result can be determined mathematically in finite time, may not terminate.
303+ //! Specifically, methods such as [`min`], which in the general case require
304+ //! traversing every element in the iterator, are likely not to return
305+ //! successfully for any infinite iterators.
306306//!
307307//! ```no_run
308308//! let positives = 1..;
309309//! let least = positives.min().unwrap(); // Oh no! An infinite loop!
310- //! // `positives.min` causes an infinite loop, so we won't reach this point!
310+ //! // `positives.min` will either overflow and panic (in debug mode),
311+ //! // or cause an infinite loop (in release mode), so we won't reach
312+ //! // this point!
311313//! println!("The least positive number is {}.", least);
312314//! ```
313315//!
You can’t perform that action at this time.
0 commit comments