Puzzle 16 | Double or Nothing |
| fn double_it(n: i32) -> i32 { |
| n * 2 |
| } |
| |
| fn double_it(n: f32) -> f32 { |
| n * 2.0 |
| } |
| |
| fn main() { |
| println!("2 * 4 = {}", double_it(2)); |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program will fail to compile, and you’ll receive the following error message:
| error[E0428]: the name "double_it" is defined multiple times |
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.