From 8edf95a1660b2c8d679754a319ca496f3e093c51 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Thu, 16 Feb 2023 16:43:24 +0100 Subject: [PATCH] Fix ranges in chapter 2 of mdbook Ranges with 0..9 have exclusive upper bounds in Rust, 0..=9 would be inclusive. > The following program should print out the numbers one through ten. --- mdbook/src/chapter_2/chapter_2_1.md | 2 +- mdbook/src/chapter_2/chapter_2_2.md | 2 +- mdbook/src/chapter_2/chapter_2_3.md | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mdbook/src/chapter_2/chapter_2_1.md b/mdbook/src/chapter_2/chapter_2_1.md index 8f8fc6b949..bccfaa913b 100644 --- a/mdbook/src/chapter_2/chapter_2_1.md +++ b/mdbook/src/chapter_2/chapter_2_1.md @@ -22,7 +22,7 @@ fn main() { worker.dataflow(|scope| { let stream1 = input.to_stream(scope); - let stream2 = (0 .. 9).to_stream(scope); + let stream2 = (0 .. 10).to_stream(scope); }); diff --git a/mdbook/src/chapter_2/chapter_2_2.md b/mdbook/src/chapter_2/chapter_2_2.md index 2ee48778d3..f16c69c19b 100644 --- a/mdbook/src/chapter_2/chapter_2_2.md +++ b/mdbook/src/chapter_2/chapter_2_2.md @@ -12,7 +12,7 @@ use timely::dataflow::operators::{ToStream, Inspect}; fn main() { timely::execute_from_args(std::env::args(), |worker| { worker.dataflow::<(),_,_>(|scope| { - (0 .. 9) + (0 .. 10) .to_stream(scope) .inspect(|x| println!("hello: {}", x)); }); diff --git a/mdbook/src/chapter_2/chapter_2_3.md b/mdbook/src/chapter_2/chapter_2_3.md index 71e5774bec..e51fc213bc 100644 --- a/mdbook/src/chapter_2/chapter_2_3.md +++ b/mdbook/src/chapter_2/chapter_2_3.md @@ -18,7 +18,7 @@ use timely::dataflow::operators::{ToStream, Inspect, Map}; fn main() { timely::execute_from_args(std::env::args(), |worker| { worker.dataflow::<(),_,_>(|scope| { - (0 .. 9) + (0 .. 10) .to_stream(scope) .map(|x| x + 1) .inspect(|x| println!("hello: {}", x)); @@ -37,7 +37,7 @@ use timely::dataflow::operators::{ToStream, Inspect, Map}; fn main() { timely::execute_from_args(std::env::args(), |worker| { worker.dataflow::<(),_,_>(|scope| { - (0 .. 9) + (0 .. 10) .to_stream(scope) .map(|x| x.to_string()) .map(|mut x| { x.truncate(5); x } ) @@ -61,7 +61,7 @@ use timely::dataflow::operators::{ToStream, Inspect, Map}; fn main() { timely::execute_from_args(std::env::args(), |worker| { worker.dataflow::<(),_,_>(|scope| { - (0 .. 9) + (0 .. 10) .to_stream(scope) .map(|x| x.to_string()) .map_in_place(|x| x.truncate(5)) @@ -81,7 +81,7 @@ use timely::dataflow::operators::{ToStream, Inspect, Map}; fn main() { timely::execute_from_args(std::env::args(), |worker| { worker.dataflow::<(),_,_>(|scope| { - (0 .. 9) + (0 .. 10) .to_stream(scope) .flat_map(|x| 0 .. x) .inspect(|x| println!("hello: {}", x)); @@ -102,7 +102,7 @@ use timely::dataflow::operators::{ToStream, Inspect, Filter}; fn main() { timely::execute_from_args(std::env::args(), |worker| { worker.dataflow::<(),_,_>(|scope| { - (0 .. 9) + (0 .. 10) .to_stream(scope) .filter(|x| *x % 2 == 0) .inspect(|x| println!("hello: {}", x));