about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-01-15 12:42:13 +0100
committerGitHub <noreply@github.com>2019-01-15 12:42:13 +0100
commita52ec3c9eeee89ea2ea6eb5716f5e796a0dc1cfc (patch)
treedfffdf6f9150301442f4e8fcd1df8dd14b02a6fe /src
parentcf436832f864ba8f79c48f8d1f8aec51258d5fe2 (diff)
parentd808f938bc47d72fd5f7ff879a33e6be9bb6a499 (diff)
downloadrust-a52ec3c9eeee89ea2ea6eb5716f5e796a0dc1cfc.tar.gz
rust-a52ec3c9eeee89ea2ea6eb5716f5e796a0dc1cfc.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/libcore/iter/iterator.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs
index 640af748172..0ad29afbade 100644
--- a/src/libcore/iter/iterator.rs
+++ b/src/libcore/iter/iterator.rs
@@ -2358,7 +2358,7 @@ pub trait Iterator {
     ///
     /// ```
     /// 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);