Skip to content

Commit 025cc4a

Browse files
authored
Unrolled build for rust-lang#135118
Rollup merge of rust-lang#135118 - ranger-ross:better-docs-on-iter-fns, r=jhpratt Clarified the documentation on `core::iter::from_fn` and `core::iter::successors` This PR clarifies the closure requirements for `core::iter::from_fn` and `core::iter::successors`. `std::iter::successors` in particular is a bit difficult to understand if you are not already familiar with the signature of [`checked_mul`](https://docs.rs/num/latest/num/trait.CheckedMul.html) used in the example. See rust-lang#135087
2 parents feb32c6 + 6243c0f commit 025cc4a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: library/core/src/iter/sources/from_fn.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::fmt;
33
/// Creates a new iterator where each iteration calls the provided closure
44
/// `F: FnMut() -> Option<T>`.
55
///
6+
/// The iterator will yield the `T`s returned from the closure.
7+
///
68
/// This allows creating a custom iterator with any behavior
79
/// without using the more verbose syntax of creating a dedicated type
810
/// and implementing the [`Iterator`] trait for it.

Diff for: library/core/src/iter/sources/successors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::iter::FusedIterator;
55
///
66
/// The iterator starts with the given first item (if any)
77
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each item’s successor.
8+
/// The iterator will yield the `T`s returned from the closure.
89
///
910
/// ```
1011
/// use std::iter::successors;

0 commit comments

Comments
 (0)