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.
This commit is contained in:
commit
a52ec3c9ee
@ -2358,7 +2358,7 @@ fn sum<S>(self) -> S
|
||||
///
|
||||
/// ```
|
||||
/// fn factorial(n: u32) -> u32 {
|
||||
/// (1..).take_while(|&i| i <= n).product()
|
||||
/// (1..=n).product()
|
||||
/// }
|
||||
/// assert_eq!(factorial(0), 1);
|
||||
/// assert_eq!(factorial(1), 1);
|
||||
|
Loading…
Reference in New Issue
Block a user