From: Ralf Jung Date: Sat, 8 Jul 2017 18:02:01 +0000 (-0700) Subject: Merge pull request #26 from TorstenScheck/fix-typos-plus-clarifications X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/7c40ab364e37362f07302da9074f2cabacffe8c7?hp=26ec22862fa81bba24e3f646cf482439999b0021 Merge pull request #26 from TorstenScheck/fix-typos-plus-clarifications Fix typos plus clarifications --- diff --git a/src/part01.rs b/src/part01.rs index 56272b2..95e4593 100644 --- a/src/part01.rs +++ b/src/part01.rs @@ -13,7 +13,7 @@ //@ For example, consider `sqr`: fn sqr(i: i32) -> i32 { i * i } //@ Between the curly braces, we are giving the *expression* that computes the return value. -//@ So we can just write `i * i`, the expression that returns the square if `i`! +//@ So we can just write `i * i`, the expression that returns the square of `i`! //@ This is very close to how mathematicians write down functions (but with more types). // Conditionals are also just expressions. This is comparable to the ternary `? :` operator diff --git a/src/part03.rs b/src/part03.rs index 2e818d1..b4bf2f3 100644 --- a/src/part03.rs +++ b/src/part03.rs @@ -6,7 +6,7 @@ //@ I/O is a complicated topic, so the code to do that is not exactly pretty - but well, //@ let's get that behind us. -// I/O is provided by the module `std::io`, so we first have import that with `use`. +// I/O is provided by the module `std::io`, so we first have to import that with `use`. // We also import the I/O *prelude*, which makes a bunch of commonly used I/O stuff // directly available. use std::io::prelude::*; diff --git a/src/part05.rs b/src/part05.rs index eaad980..adbe5c7 100644 --- a/src/part05.rs +++ b/src/part05.rs @@ -47,7 +47,8 @@ impl BigInt { } } - // We can convert any vector of digits into a number, by removing trailing zeros. The `mut` + // Any vector of digits, which meets the structure of BigInt's `data` field, can be easily + // converted into a big number just by removing trailing zeros. The `mut` // declaration for `v` here is just like the one in `let mut ...`: We completely own `v`, but Rust // still asks us to make our intention of modifying it explicit. This `mut` is *not* part of the // type of `from_vec` - the caller has to give up ownership of `v` anyway, so they don't care anymore diff --git a/src/part10.rs b/src/part10.rs index 66d18ff..0c90369 100644 --- a/src/part10.rs +++ b/src/part10.rs @@ -81,7 +81,7 @@ impl BigInt { pub fn print_with_prefix(b: &BigInt, prefix: String) { //@ The syntax for closures is `|arg1, arg2, ...| code`. Notice that the closure can reference variables like `prefix` that it did not //@ take as argument - variables that happen to be present *outside* of the closure. We say that the closure *captures* - //@ variables. Rust will now automatically create a type (like `PrintWithStruct`) for the environment of the closure + //@ variables. Rust will now automatically create a type (like `PrintWithString`) for the environment of the closure //@ with fields for every captured variable, implement the closure trait for this type such that the action performed //@ is given by the code of the closure, and finally it will instantiate the environment type here at the definition site //@ of the closure and fill it appropriately. diff --git a/src/part11.rs b/src/part11.rs index 5134401..757f205 100644 --- a/src/part11.rs +++ b/src/part11.rs @@ -115,6 +115,6 @@ pub fn main() { // **Exercise 11.1**: We made the arbitrary choice of using `i32` for the arguments. Generalize the data structures above // to work with an arbitrary type `T` that's passed to the callbacks. Since you need to call multiple callbacks with the -// same `t: T`, you will either have to restrict `T` to `Copy` types, or pass a reference. +// same `val: T` (in our `call` function), you will either have to restrict `T` to `Copy` types, or pass a reference. //@ [index](main.html) | [previous](part10.html) | [raw source](workspace/src/part11.rs) | [next](part12.html)