From 91c461f73acea274618b2001e574fd6fb7c711fd Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 24 Feb 2017 17:36:55 +0000 Subject: [PATCH] rebuild pages at 25ed4f0 --- ch13-02-iterators.html | 28 +++++++++++++++++++++++++++- print.html | 28 +++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/ch13-02-iterators.html b/ch13-02-iterators.html index 93856387e..4380cd406 100644 --- a/ch13-02-iterators.html +++ b/ch13-02-iterators.html @@ -257,7 +257,33 @@ an instance of Counter produces, pair those values with values prod another Counter instance after skipping the first value that instance produces, multiply each pair together, keep only those results that are divisible by three, and add all the resulting values together, we could do so:

-
let sum: u32 = Counter::new().take(5)
+
# struct Counter {
+#     count: u32,
+# }
+#
+# impl Counter {
+#     fn new() -> Counter {
+#         Counter { count: 0 }
+#     }
+# }
+#
+# impl Iterator for Counter {
+#     // Our iterator will produce u32s
+#     type Item = u32;
+#
+#     fn next(&mut self) -> Option<Self::Item> {
+#         // increment our count. This is why we started at zero.
+#         self.count += 1;
+#
+#         // check to see if we've finished counting or not.
+#         if self.count < 6 {
+#             Some(self.count)
+#         } else {
+#             None
+#         }
+#     }
+# }
+let sum: u32 = Counter::new().take(5)
                              .zip(Counter::new().skip(1))
                              .map(|(a, b)| a * b)
                              .filter(|x| x % 3 == 0)
diff --git a/print.html b/print.html
index 1b2a1e6db..87fbe931c 100644
--- a/print.html
+++ b/print.html
@@ -11249,7 +11249,33 @@ an instance of Counter produces, pair those values with values prod
 another Counter instance after skipping the first value that instance
 produces, multiply each pair together, keep only those results that are
 divisible by three, and add all the resulting values together, we could do so:

-
let sum: u32 = Counter::new().take(5)
+
# struct Counter {
+#     count: u32,
+# }
+#
+# impl Counter {
+#     fn new() -> Counter {
+#         Counter { count: 0 }
+#     }
+# }
+#
+# impl Iterator for Counter {
+#     // Our iterator will produce u32s
+#     type Item = u32;
+#
+#     fn next(&mut self) -> Option<Self::Item> {
+#         // increment our count. This is why we started at zero.
+#         self.count += 1;
+#
+#         // check to see if we've finished counting or not.
+#         if self.count < 6 {
+#             Some(self.count)
+#         } else {
+#             None
+#         }
+#     }
+# }
+let sum: u32 = Counter::new().take(5)
                              .zip(Counter::new().skip(1))
                              .map(|(a, b)| a * b)
                              .filter(|x| x % 3 == 0)