From: Ralf Jung Date: Fri, 26 Jun 2015 20:42:54 +0000 (+0200) Subject: tuning X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/fff8ebeb3f0b84c71275cbb5adee0aad6114f79b?ds=inline;hp=4f61be32dd480f23a7fef05ee66c42ae27c980c6 tuning --- diff --git a/src/part00.rs b/src/part00.rs index 06bb205..cd1e7cc 100644 --- a/src/part00.rs +++ b/src/part00.rs @@ -35,8 +35,7 @@ fn vec_min(vec: Vec) -> NumberOrNothing { //@ immutable per default, and you need to tell Rust if you want //@ to change a variable later. - // Now we want to *iterate* over the list. Rust has some nice syntax for - // iterators: + // Now we want to *iterate* over the list. Rust has some nice syntax for iterators: for el in vec { // So `el` is al element of the list. We need to update `min` accordingly, but how do we get the current // number in there? This is what pattern matching can do: diff --git a/src/part03.rs b/src/part03.rs index 4a69aab..ecb8b15 100644 --- a/src/part03.rs +++ b/src/part03.rs @@ -33,8 +33,8 @@ fn read_vec() -> Vec { //@ details.) for line in stdin.lock().lines() { // Rust's type for (dynamic, growable) strings is `String`. However, our variable `line` - // here is not yet of that type: It rather has type `io::Result`. - //@ The problem with I/O is that it can always go wrong. The type of `line`is a lot like `Option` ("a `String` or + // here is not yet of that type: It has type `io::Result`. + //@ The problem with I/O is that it can always go wrong. The type of `line` is a lot like `Option` ("a `String` or //@ nothing"), but in the case of "nothing", there is additional information about the error. //@ Again, I recommend to check [the documentation](http://doc.rust-lang.org/stable/std/io/type.Result.html). //@ You will see that `io::Result` is actually just an alias for `Result`, so click on that to obtain diff --git a/src/part06.rs b/src/part06.rs index 00a2bde..35cd5a9 100644 --- a/src/part06.rs +++ b/src/part06.rs @@ -25,8 +25,8 @@ impl BigInt { } } -// Now we can write `vec_min`. However, in order to make it type-check, we have to make a full (deep) copy of e -// by calling `clone()`. +// Now we can write `vec_min`. +//@ However, in order to make it type-check, we have to make a full (deep) copy of e by calling `clone()`. fn vec_min(v: &Vec) -> Option { let mut min: Option = None; for e in v { diff --git a/workspace/src/part00.rs b/workspace/src/part00.rs index bf6a9fd..65769ef 100644 --- a/workspace/src/part00.rs +++ b/workspace/src/part00.rs @@ -17,8 +17,7 @@ enum NumberOrNothing { fn vec_min(vec: Vec) -> NumberOrNothing { let mut min = NumberOrNothing::Nothing; - // Now we want to *iterate* over the list. Rust has some nice syntax for - // iterators: + // Now we want to *iterate* over the list. Rust has some nice syntax for iterators: for el in vec { // So `el` is al element of the list. We need to update `min` accordingly, but how do we get the current // number in there? This is what pattern matching can do: diff --git a/workspace/src/part03.rs b/workspace/src/part03.rs index 08cca72..96ac4bf 100644 --- a/workspace/src/part03.rs +++ b/workspace/src/part03.rs @@ -17,7 +17,7 @@ fn read_vec() -> Vec { println!("Enter a list of numbers, one per line. End with Ctrl-D."); for line in stdin.lock().lines() { // Rust's type for (dynamic, growable) strings is `String`. However, our variable `line` - // here is not yet of that type: It rather has type `io::Result`. + // here is not yet of that type: It has type `io::Result`. // I chose the same name (`line`) for the new variable to ensure that I will never, accidentally, // access the "old" `line` again. diff --git a/workspace/src/part06.rs b/workspace/src/part06.rs index 8b69022..a62560e 100644 --- a/workspace/src/part06.rs +++ b/workspace/src/part06.rs @@ -24,8 +24,7 @@ impl BigInt { } } -// Now we can write `vec_min`. However, in order to make it type-check, we have to make a full (deep) copy of e -// by calling `clone()`. +// Now we can write `vec_min`. fn vec_min(v: &Vec) -> Option { let mut min: Option = None; for e in v {