Skip to content

Docs: Better explanation of return values for min, max functions for the Iterator trait #39955

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

Merged
merged 1 commit into from
Feb 20, 2017
Merged
Changes from all commits
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
28 changes: 22 additions & 6 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,16 +1616,20 @@ pub trait Iterator {
/// Returns the maximum element of an iterator.
///
/// If several elements are equally maximum, the last element is
/// returned.
/// returned. If the iterator is empty, [`None`] is returned.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let a = [1, 2, 3];
/// let b: Vec<u32> = Vec::new();
///
/// assert_eq!(a.iter().max(), Some(&3));
/// assert_eq!(b.iter().max(), None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -1642,16 +1646,20 @@ pub trait Iterator {
/// Returns the minimum element of an iterator.
///
/// If several elements are equally minimum, the first element is
/// returned.
/// returned. If the iterator is empty, [`None`] is returned.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let a = [1, 2, 3];
/// let b: Vec<u32> = Vec::new();
///
/// assert_eq!(a.iter().min(), Some(&1));
/// assert_eq!(b.iter().min(), None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -1669,7 +1677,9 @@ pub trait Iterator {
/// specified function.
///
/// If several elements are equally maximum, the last element is
/// returned.
/// returned. If the iterator is empty, [`None`] is returned.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
Expand All @@ -1694,7 +1704,9 @@ pub trait Iterator {
/// specified comparison function.
///
/// If several elements are equally maximum, the last element is
/// returned.
/// returned. If the iterator is empty, [`None`] is returned.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
Expand All @@ -1719,7 +1731,9 @@ pub trait Iterator {
/// specified function.
///
/// If several elements are equally minimum, the first element is
/// returned.
/// returned. If the iterator is empty, [`None`] is returned.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
Expand All @@ -1743,7 +1757,9 @@ pub trait Iterator {
/// specified comparison function.
///
/// If several elements are equally minimum, the first element is
/// returned.
/// returned. If the iterator is empty, [`None`] is returned.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
Expand Down