X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/7c40ab364e37362f07302da9074f2cabacffe8c7..8eb07931e8a0427fd63cd2245602858881279a2c:/src/part01.rs diff --git a/src/part01.rs b/src/part01.rs index 95e4593..e00cf53 100644 --- a/src/part01.rs +++ b/src/part01.rs @@ -43,9 +43,10 @@ fn compute_stuff(x: i32) -> i32 { // Let us now refactor `vec_min`. fn vec_min(v: Vec) -> NumberOrNothing { - //@ Remember that helper function `min_i32`? Rust allows us to define such helper functions *inside* other - //@ functions. This is just a matter of namespacing, the inner function has no access to the data of the outer - //@ one. Still, being able to nicely group functions can significantly increase readability. + //@ Remember that helper function `min_i32`? Rust allows us to define such helper functions + //@ *inside* other functions. This is just a matter of namespacing, the inner function has no + //@ access to the data of the outer one. Still, being able to nicely group functions can + //@ significantly increase readability. fn min_i32(a: i32, b: i32) -> i32 { if a < b { a } else { b } /*@*/ } @@ -86,7 +87,7 @@ impl NumberOrNothing { //@ methods on an `enum` (and also on `struct`, which we will learn about later) //@ is independent of the definition of the type. `self` is like `this` in other //@ languages, and its type is always implicit. So `print` is now a method that -//@ takes as first argument a `NumberOrNothing`, just like `print_number_or_nothing`. +//@ takes `NumberOrNothing` as the first argument, just like `print_number_or_nothing`. //@ //@ Try making `number_or_default` from above an inherent method as well! @@ -106,4 +107,5 @@ pub fn main() { // **Exercise 01.2**: Write a function `vec_print` that takes a vector and prints all its elements. -//@ [index](main.html) | [previous](part00.html) | [raw source](workspace/src/part01.rs) | [next](part02.html) +//@ [index](main.html) | [previous](part00.html) | [raw source](workspace/src/part01.rs) | +//@ [next](part02.html)