projects
/
rust-101.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix the patching monkeys
[rust-101.git]
/
workspace
/
src
/
part01.rs
diff --git
a/workspace/src/part01.rs
b/workspace/src/part01.rs
index 1b2460c9783c94d9a248710ec2a3aa4a5b0ca93e..ed6717ca3b8111f7b61afc56f0b863c6f3fffc73 100644
(file)
--- a/
workspace/src/part01.rs
+++ b/
workspace/src/part01.rs
@@
-24,6
+24,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 {
fn min_i32(a: i32, b: i32) -> i32 {
// Let us now refactor `vec_min`.
fn vec_min(v: Vec<i32>) -> NumberOrNothing {
fn min_i32(a: i32, b: i32) -> i32 {