rebuild pages at 25ed4f0

This commit is contained in:
Steve Klabnik
2017-02-24 17:36:55 +00:00
parent 1e6294d3d4
commit 91c461f73a
2 changed files with 54 additions and 2 deletions
+27 -1
View File
@@ -257,7 +257,33 @@ an instance of <code>Counter</code> produces, pair those values with values prod
another <code>Counter</code> 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:</p>
<pre><code class="language-rust,ignore">let sum: u32 = Counter::new().take(5)
<pre><code class="language-rust"># struct Counter {
# count: u32,
# }
#
# impl Counter {
# fn new() -&gt; Counter {
# Counter { count: 0 }
# }
# }
#
# impl Iterator for Counter {
# // Our iterator will produce u32s
# type Item = u32;
#
# fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt; {
# // 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 &lt; 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)
+27 -1
View File
@@ -11249,7 +11249,33 @@ an instance of <code>Counter</code> produces, pair those values with values prod
another <code>Counter</code> 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:</p>
<pre><code class="language-rust,ignore">let sum: u32 = Counter::new().take(5)
<pre><code class="language-rust"># struct Counter {
# count: u32,
# }
#
# impl Counter {
# fn new() -&gt; Counter {
# Counter { count: 0 }
# }
# }
#
# impl Iterator for Counter {
# // Our iterator will produce u32s
# type Item = u32;
#
# fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt; {
# // 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 &lt; 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)