projects
/
rust-101.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
link to drop RFC
[rust-101.git]
/
src
/
part01.rs
diff --git
a/src/part01.rs
b/src/part01.rs
index ed4f73fead839c97590ceeaef637b0b57b9783b1..e73da231a0cc288fe2272e8e764d15c867eabfba 100644
(file)
--- a/
src/part01.rs
+++ b/
src/part01.rs
@@
-35,6
+35,12
@@
fn number_or_default(n: NumberOrNothing, default: i32) -> i32 {
}
}
}
}
+// It is even the case that blocks are expressions, evaluating to the last expression they contain.
+fn compute_stuff(x: i32) -> i32 {
+ let y = { let z = x*x; z + 14 };
+ y*y
+}
+
// 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
// 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