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:
Mazdak Farrokhzad
2019-01-15 12:42:13 +01:00
committed by GitHub
+1 -1
View File
@@ -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);