projects
/
rust-101.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
4f61be3
)
tuning
author
Ralf Jung
<post@ralfj.de>
Fri, 26 Jun 2015 20:42:54 +0000
(22:42 +0200)
committer
Ralf Jung
<post@ralfj.de>
Fri, 26 Jun 2015 20:42:54 +0000
(22:42 +0200)
src/part00.rs
patch
|
blob
|
history
src/part03.rs
patch
|
blob
|
history
src/part06.rs
patch
|
blob
|
history
workspace/src/part00.rs
patch
|
blob
|
history
workspace/src/part03.rs
patch
|
blob
|
history
workspace/src/part06.rs
patch
|
blob
|
history
diff --git
a/src/part00.rs
b/src/part00.rs
index 06bb20593cd316d162152dbc2c530a2cba6a2a58..cd1e7cc26d32a03da7c3d8c6dfaa66d0af3f2aa2 100644
(file)
--- a/
src/part00.rs
+++ b/
src/part00.rs
@@
-35,8
+35,7
@@
fn vec_min(vec: Vec<i32>) -> NumberOrNothing {
//@ immutable per default, and you need to tell Rust if you want
//@ to change a variable later.
//@ 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:
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 4a69aaba7f42b2138e364cb8e96485717de9e8a1..ecb8b1583807c15ff20017509805c1f2bab3880e 100644
(file)
--- a/
src/part03.rs
+++ b/
src/part03.rs
@@
-33,8
+33,8
@@
fn read_vec() -> Vec<i32> {
//@ details.)
for line in stdin.lock().lines() {
// Rust's type for (dynamic, growable) strings is `String`. However, our variable `line`
//@ 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<String>`.
- //@ The problem with I/O is that it can always go wrong. The type of `line`is a lot like `Option<String>` ("a `String` or
+ // here is not yet of that type: It has type `io::Result<String>`.
+ //@ The problem with I/O is that it can always go wrong. The type of `line`
is a lot like `Option<String>` ("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
//@ 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 00a2bde39038dd3478bb3ac1c44f6c829080bd0e..35cd5a9dc0a82b8a35daf9618ad7498dca0d6937 100644
(file)
--- 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<BigInt>) -> Option<BigInt> {
let mut min: Option<BigInt> = None;
for e in v {
fn vec_min(v: &Vec<BigInt>) -> Option<BigInt> {
let mut min: Option<BigInt> = None;
for e in v {
diff --git
a/workspace/src/part00.rs
b/workspace/src/part00.rs
index bf6a9fdacd15a3a426c52428f1901bfd3bde137d..65769ef3c59374aad1ece636d11ef3b28406a0f8 100644
(file)
--- a/
workspace/src/part00.rs
+++ b/
workspace/src/part00.rs
@@
-17,8
+17,7
@@
enum NumberOrNothing {
fn vec_min(vec: Vec<i32>) -> NumberOrNothing {
let mut min = NumberOrNothing::Nothing;
fn vec_min(vec: Vec<i32>) -> 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:
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 08cca72b0ebc5a9777b24217478dfd211c4aaa8f..96ac4bf44b787615b1ca06cc6822de936f99d566 100644
(file)
--- a/
workspace/src/part03.rs
+++ b/
workspace/src/part03.rs
@@
-17,7
+17,7
@@
fn read_vec() -> Vec<i32> {
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`
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<String>`.
+ // here is not yet of that type: It has type `io::Result<String>`.
// I chose the same name (`line`) for the new variable to ensure that I will never, accidentally,
// access the "old" `line` again.
// 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 8b69022bfa3792ffefebbe1ff9bb37d5bf5edbf9..a62560ea4bb300b7f725f543c91e773366b22cc8 100644
(file)
--- 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<BigInt>) -> Option<BigInt> {
let mut min: Option<BigInt> = None;
for e in v {
fn vec_min(v: &Vec<BigInt>) -> Option<BigInt> {
let mut min: Option<BigInt> = None;
for e in v {