Puzzle 8 | Walks Like a Duck, Quacks Like a Duck |
| fn double_it(n: u64, _: i32) -> u64 { |
| n * 2 |
| } |
| |
| fn main() { |
| let one: i32 = 1; |
| let n = double_it(one as _, 3); |
| println!("{}", n); |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program will display the following output, showing no warnings or errors:
| 2 |
Discussion
We find two surprises:
-
You can name a function parameter ...
Get Rust Brain Teasers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.