Skip to content

Commit a52ec3c

Browse files
authored
Rollup merge of #57608 - timvisee:master, r=frewsxcv
Simplify 'product' factorial example This simplifies the [`factorial(n: 32)`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#examples-46) implementation as example for the `Iterator::product()` function. It currently uses unnecessary additional complexity. Although very minimal, I do not want to include it in some other irrelevant PR.
2 parents cf43683 + d808f93 commit a52ec3c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/iter/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2358,7 +2358,7 @@ pub trait Iterator {
23582358
///
23592359
/// ```
23602360
/// fn factorial(n: u32) -> u32 {
2361-
/// (1..).take_while(|&i| i <= n).product()
2361+
/// (1..=n).product()
23622362
/// }
23632363
/// assert_eq!(factorial(0), 1);
23642364
/// assert_eq!(factorial(1), 1);

0 commit comments

Comments
 (0)