label = "`{Self}` is not an iterator",
message = "`{Self}` is not an iterator"
)]
+#[doc(spotlight)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub trait Iterator {
/// The type of the elements being iterated over.
/// again may or may not eventually start returning [`Some(Item)`] again at some
/// point.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- /// [`Some(Item)`]: ../../std/option/enum.Option.html#variant.Some
+ /// [`Some(Item)`]: Some
///
/// # Examples
///
/// The default implementation returns `(0, `[`None`]`)` which is correct for any
/// iterator.
///
- /// [`usize`]: ../../std/primitive.usize.html
- /// [`Option`]: ../../std/option/enum.Option.html
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [`usize`]: type@usize
///
/// # Examples
///
/// called at least once even if the iterator does not have any elements.
///
/// [`next`]: #tymethod.next
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- /// [`Some`]: ../../std/option/enum.Option.html#variant.Some
///
/// # Overflow Behavior
///
/// This function might panic if the iterator has more than [`usize::MAX`]
/// elements.
///
- /// [`usize::MAX`]: ../../std/usize/constant.MAX.html
+ /// [`usize::MAX`]: crate::usize::MAX
///
/// # Examples
///
/// doing so, it keeps track of the current element. After [`None`] is
/// returned, `last()` will then return the last element it saw.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// Basic usage:
/// `nth()` will return [`None`] if `n` is greater than or equal to the length of the
/// iterator.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// Basic usage:
/// assert_eq!((2, 'o'), zipper[2]);
/// ```
///
- /// [`enumerate`]: trait.Iterator.html#method.enumerate
- /// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [`enumerate`]: #method.enumerate
+ /// [`next`]: #tymethod.next
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
/// more idiomatic to use [`for`] than `map()`.
///
/// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
- /// [`FnMut`]: ../../std/ops/trait.FnMut.html
+ /// [`FnMut`]: crate::ops::FnMut
///
/// # Examples
///
/// assert_eq!(iter.next(), None);
/// ```
///
- /// [`Option<T>`]: ../../std/option/enum.Option.html
- /// [`Some`]: ../../std/option/enum.Option.html#variant.Some
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [`Option<T>`]: Option
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
/// The returned iterator might panic if the to-be-returned index would
/// overflow a [`usize`].
///
- /// [`usize::MAX`]: ../../std/usize/constant.MAX.html
- /// [`usize`]: ../../std/primitive.usize.html
+ /// [`usize`]: type@usize
+ /// [`usize::MAX`]: crate::usize::MAX
/// [`zip`]: #method.zip
///
/// # Examples
/// anything other than fetching the next value) of the [`next`] method
/// will occur.
///
- /// [`peek`]: struct.Peekable.html#method.peek
- /// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next
+ /// [`peek`]: crate::iter::Peekable::peek
+ /// [`next`]: #tymethod.next
///
/// # Examples
///
/// It is also not specified what this iterator returns after the first` None` is returned.
/// If you need fused iterator, use [`fuse`].
///
- /// [`Some`]: ../../std/option/enum.Option.html#variant.Some
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
/// [`fuse`]: #method.fuse
#[inline]
#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]
/// iterator and the return value from the closure, an [`Option`], is
/// yielded by the iterator.
///
- /// [`Option`]: ../../std/option/enum.Option.html
- ///
/// # Examples
///
/// Basic usage:
/// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a
/// [`None`] is given, it will always return [`None`] forever.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- /// [`Some(T)`]: ../../std/option/enum.Option.html#variant.Some
+ /// [`Some(T)`]: Some
///
/// # Examples
///
/// assert_eq!(Ok(vec![1, 3]), result);
/// ```
///
- /// [`iter`]: ../../std/iter/trait.Iterator.html#tymethod.next
+ /// [`iter`]: #tymethod.next
/// [`String`]: ../../std/string/struct.String.html
- /// [`char`]: ../../std/primitive.char.html
- /// [`Result`]: ../../std/result/enum.Result.html
+ /// [`char`]: type@char
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
/// argument is a double reference. You can see this effect in the
/// examples below, with `&&x`.
///
- /// [`Some(element)`]: ../../std/option/enum.Option.html#variant.Some
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [`Some(element)`]: Some
///
/// # Examples
///
/// This function might panic if the iterator has more than `usize::MAX`
/// non-matching elements.
///
- /// [`Some(index)`]: ../../std/option/enum.Option.html#variant.Some
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- /// [`usize::MAX`]: ../../std/usize/constant.MAX.html
+ /// [`Some(index)`]: Some
+ /// [`usize::MAX`]: crate::usize::MAX
///
/// # Examples
///
/// `rposition()` is short-circuiting; in other words, it will stop
/// processing as soon as it finds a `true`.
///
- /// [`Some(index)`]: ../../std/option/enum.Option.html#variant.Some
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [`Some(index)`]: Some
///
/// # Examples
///
/// If several elements are equally maximum, the last element is
/// returned. If the iterator is empty, [`None`] is returned.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// Basic usage:
/// If several elements are equally minimum, the first element is
/// returned. If the iterator is empty, [`None`] is returned.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// Basic usage:
/// If several elements are equally maximum, the last element is
/// returned. If the iterator is empty, [`None`] is returned.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// ```
/// If several elements are equally maximum, the last element is
/// returned. If the iterator is empty, [`None`] is returned.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// ```
/// If several elements are equally minimum, the first element is
/// returned. If the iterator is empty, [`None`] is returned.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// ```
/// If several elements are equally minimum, the first element is
/// returned. If the iterator is empty, [`None`] is returned.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// ```
/// This is useful when you have an iterator over `&T`, but you need an
/// iterator over `T`.
///
- /// [`clone`]: ../../std/clone/trait.Clone.html#tymethod.clone
+ /// [`clone`]: crate::clone::Clone::clone
///
/// # Examples
///
/// from the beginning. After iterating again, it will start at the
/// beginning again. And again. And again. Forever.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// Basic usage:
/// assert!(![0.0, 1.0, f32::NAN].iter().is_sorted_by(|a, b| a.partial_cmp(b)));
/// ```
///
- /// [`is_sorted`]: trait.Iterator.html#method.is_sorted
+ /// [`is_sorted`]: #method.is_sorted
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
fn is_sorted_by<F>(mut self, mut compare: F) -> bool
where
/// the elements, as determined by `f`. Apart from that, it's equivalent to [`is_sorted`]; see
/// its documentation for more information.
///
- /// [`is_sorted`]: trait.Iterator.html#method.is_sorted
+ /// [`is_sorted`]: #method.is_sorted
///
/// # Examples
///