From: Ralf Jung Date: Sun, 11 Feb 2018 16:50:36 +0000 (+0100) Subject: fix some more nits X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/488127b6522769f834f8df4ea7c406396782d7e8?ds=sidebyside;hp=--cc fix some more nits --- 488127b6522769f834f8df4ea7c406396782d7e8 diff --git a/src/part00.rs b/src/part00.rs index eaed3d7..d8b4ed7 100644 --- a/src/part00.rs +++ b/src/part00.rs @@ -5,7 +5,6 @@ // minimum of a list. //@ ## Getting started - //@ Let us start by thinking about the *type* of our function. Rust forces us to give the types of //@ all arguments, and the return type, before we even start writing the body. In the case of our //@ minimum function, we may be inclined to say that it returns a number. But then we would be in diff --git a/src/part03.rs b/src/part03.rs index 2a5eb16..44431e6 100644 --- a/src/part03.rs +++ b/src/part03.rs @@ -30,7 +30,7 @@ fn read_vec() -> Vec { //@ concurrently, that also reads from standard input? The result would be a mess. Hence //@ Rust requires us to `lock` standard input if we want to perform large operations on //@ it. (See [the documentation](https://doc.rust-lang.org/stable/std/io/struct.Stdin.html) for - //@ more details.) + //@ more 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 has type `io::Result`. diff --git a/src/part04.rs b/src/part04.rs index faa3e31..21654cd 100644 --- a/src/part04.rs +++ b/src/part04.rs @@ -101,8 +101,9 @@ fn shared_ref_demo() { //@ There is a second way to borrow something, a second kind of reference: The *mutable reference*. //@ This is a reference that comes with the promise that nobody else has *any kind of access* to //@ the referee - in contrast to shared references, there is no aliasing with mutable references. -//@ It is thus always safe to perform mutation through such a reference. -//@ Because there cannot be another reference to the same data, we could also call it a *unique* reference, but that is not their official name. +//@ It is thus always safe to perform mutation through such a reference. Because there cannot be +//@ another reference to the same data, we could also call it a *unique* reference, but that is not +//@ their official name. //@ As an example, consider a function which increments every element of a vector by 1. //@ The type `&mut Vec` is the type of mutable references to `vec`. Because the reference diff --git a/src/part05.rs b/src/part05.rs index c0a573b..7ad8754 100644 --- a/src/part05.rs +++ b/src/part05.rs @@ -6,6 +6,7 @@ //@ In the course of the next few parts, we are going to build a data-structure for computations //@ with *big* numbers. We would like to not have an upper bound to how large these numbers can //@ get, with the memory of the machine being the only limit. +//@ //@ We start by deciding how to represent such big numbers. One possibility here is to use a vector //@ "digits" of the number. This is like "1337" being a vector of four digits (1, 3, 3, 7), except //@ that we will use `u64` as type of our digits, meaning we have 2^64 individual digits. Now we diff --git a/src/part07.rs b/src/part07.rs index b2ef809..b04d766 100644 --- a/src/part07.rs +++ b/src/part07.rs @@ -153,7 +153,6 @@ fn test_vec_min() { // **Exercise 07.1**: Add some more testcases. In particular, make sure you test the behavior of // `vec_min` on an empty vector. Also add tests for `BigInt::from_vec` (in particular, removing // trailing zeros). Finally, break one of your functions in a subtle way and watch the test fail. -// // **Exercise 07.2**: Go back to your good ol' `SomethingOrNothing`, and implement `Display` for it. // (This will, of course, need a `Display` bound on `T`.) Then you should be able to use them with