Clarified the documentation on core::iter::from_fn and core::iter::successors
This commit is contained in:
parent
8417f8311f
commit
6243c0f818
2 changed files with 3 additions and 0 deletions
|
@ -3,6 +3,8 @@ use crate::fmt;
|
||||||
/// Creates a new iterator where each iteration calls the provided closure
|
/// Creates a new iterator where each iteration calls the provided closure
|
||||||
/// `F: FnMut() -> Option<T>`.
|
/// `F: FnMut() -> Option<T>`.
|
||||||
///
|
///
|
||||||
|
/// The iterator will yield the `T`s returned from the closure.
|
||||||
|
///
|
||||||
/// This allows creating a custom iterator with any behavior
|
/// This allows creating a custom iterator with any behavior
|
||||||
/// without using the more verbose syntax of creating a dedicated type
|
/// without using the more verbose syntax of creating a dedicated type
|
||||||
/// and implementing the [`Iterator`] trait for it.
|
/// and implementing the [`Iterator`] trait for it.
|
||||||
|
|
|
@ -5,6 +5,7 @@ use crate::iter::FusedIterator;
|
||||||
///
|
///
|
||||||
/// The iterator starts with the given first item (if any)
|
/// The iterator starts with the given first item (if any)
|
||||||
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each item’s successor.
|
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each item’s successor.
|
||||||
|
/// The iterator will yield the `T`s returned from the closure.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::iter::successors;
|
/// use std::iter::successors;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue