Core Beginner
00 Variables
Rust bindings are immutable unless you say otherwise, and constants carry an explicit type.
Shadow n: parse the text into a number, then shadow again with the doubled value.
Hints
- Shadowing: a second
let n = ...makes a NEW binding -- even with a different type. n.trim().parse::<i32>().unwrap()turns the text into a number.
Reveal solution
fn parse_and_double(n: &str) -> i32 {
let n: i32 = n.trim().parse().unwrap();
let n = n * 2;
n
}