Merge pull request #29 from teknico/shorten-lines
[rust-101.git] / src / part01.rs
index 56272b2f68c294c879171bee569068cd482d2522..a4537acbc18f05e621fc0b5d05cbbffd3bb7bfcd 100644 (file)
@@ -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
@@ -43,9 +43,10 @@ fn compute_stuff(x: i32) -> i32 {
 
 // Let us now refactor `vec_min`.
 fn vec_min(v: Vec<i32>) -> 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 }                                   /*@*/
     }
@@ -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)