I am a beginner Rustacean. I am getting aforementioned error. But unable to find the error in code. The error screen shot:
The code is:
use std::io;
fn main() {
loop {
println!("1: Convert temperature from Fahrenheit to Celsius.");
println!("2: Convert temperature from Celsius to Fahrenheit.");
println!("3: Quit");
println!("Enter your choice (1, 2, 3);
let mut choice = String::new();
io::stdin()
.read_line(&mut choice)
.expect("Failed to read line");
let choice: u32 = choice.trim().parse().expect("Invalid Input");
if choice == 1 {
println!("Enter temperature in Fahrenheit:");
let mut fahrenheit = String::new();
io::stdin()
.read_line(&mut fahrenheit)
.expect("Failed to read line");
let fahrenheit: f32 = fahrenheit.trim().parse().expect("Invalid Input");
let result: f32 = (fahrenheit - 32 as f32) / 1.8;
println!("Temperature in Celsius {}",result );
}
if choice == 2 {
println!("Enter temperature in Celsius:");
let mut celsius = String::new();
io::stdin()
.read_line(&mut celsius)
.expect("Failed to read line");
let celsius: f32 = celsius.trim().parse().expect("Invalid Input");
let result: f32 = (celsius * 1.8)+(32 as f32);
println!("Temperature in Fahrenheit {}",result );
}
if choice == 3{
break;
}
}
}
I can't see any error in the code. Please help me out. Thanks in advance