refactor - cleaned up code
1 file changed, 3 insertions(+), 9 deletions(-)
@@ -1,5 +1,4 @@
use std::io;
use std::process;
fn main() {
println!("Welcome to the temperature converter!");
@@ -20,22 +19,17 @@
if direction == "q" || direction == "Q" {
break;
} if direction != "1" && direction != "2" {
} else if direction != "1" && direction != "2" {
println!("Please make a valid selection!");
continue;
}
let direction: u32 = direction.parse().expect("Please type a number!");
let start_temp = read_temp();
if direction == 1 {
if direction == "1" {
println!("{start_temp}F is equal to {}C",farenheit_to_celsius(start_temp));
} else if direction == 2 {
println!("{start_temp}C is equal to {}F", celsius_to_farenheit(start_temp));
} else {
println!("Please choose 1 or 2!");
continue;
println!("{start_temp}C is equal to {}F", celsius_to_farenheit(start_temp));
}
}
}