X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/29958c0fd33c5e714b52bed79a1832113c43b8d8..342e299d8a8fd79f07960312b73e241c6cc0400e:/workspace/src/part01.rs diff --git a/workspace/src/part01.rs b/workspace/src/part01.rs index 1b2460c..ed6717c 100644 --- 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) -> NumberOrNothing { fn min_i32(a: i32, b: i32) -> i32 {