Why and how does this line work:
let guess: f64 = "42".parse().expect("Not a number!");
But this does not?
let guess: i32 = "42.0".parse().expect("Not a number!");
Resulting in:
thread 'main' panicked at 'Not a number!: ParseIntError { kind: InvalidDigit }'
What is the correct way to parse "float" &str to integer?
Update:
I found this to work:
let guess: i32 = "42.0".parse::<f64>().expect("Not a number!") as i32;
However I don't understand the mechanics of how it works and if it is the correct way to do it?