// 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
//@ 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<String>`.
//@ 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<i32>` is the type of mutable references to `vec<i32>`. Because the reference
//@ 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
// **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