Puzzle 8Walks 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:



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 live online training, plus books, videos, and digital content from nearly 200 publishers.