Add a note about side effects for "peekable" iterators
This commit is contained in:
parent
74b3684d00
commit
c29585ca5b
@ -901,12 +901,17 @@ pub trait Iterator {
|
|||||||
Enumerate { iter: self, count: 0 }
|
Enumerate { iter: self, count: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an iterator which can look at the `next()` element without
|
/// Creates an iterator which can use `peek` to look at the next element of
|
||||||
/// consuming it.
|
/// the iterator without consuming it.
|
||||||
///
|
///
|
||||||
/// Adds a [`peek()`] method to an iterator. See its documentation for
|
/// Adds a [`peek()`] method to an iterator. See its documentation for
|
||||||
/// more information.
|
/// more information.
|
||||||
///
|
///
|
||||||
|
/// Note that the underlying iterator is still advanced when `peek` is
|
||||||
|
/// called for the first time: In order to retrieve the next element,
|
||||||
|
/// `next` is called on the underlying iterator, hence any side effects of
|
||||||
|
/// the `next` method will occur.
|
||||||
|
///
|
||||||
/// [`peek()`]: struct.Peekable.html#method.peek
|
/// [`peek()`]: struct.Peekable.html#method.peek
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
Loading…
Reference in New Issue
Block a user