update temperature version

This commit is contained in:
Pecha 2020-03-01 16:21:22 +10:00
parent f830d83b92
commit 090a365d63
3 changed files with 10 additions and 4 deletions

View file

@ -2,5 +2,5 @@
# It is not intended for manual editing.
[[package]]
name = "temperature"
version = "0.1.0"
version = "0.2.0"

View file

@ -1,6 +1,6 @@
[package]
name = "temperature"
version = "0.1.0"
version = "0.2.0"
authors = ["Pecha <petralawson@tuta.io>"]
edition = "2018"

View file

@ -5,8 +5,8 @@ fn main() {
loop {
let mut scale = String::new();
let mut temperature = String::new();
let mut o_scale = String::new();
let mut o_scale = String::new();
println!("Please enter a scale to convert from- Farenheit (F) or Celsius (C)");
io::stdin().read_line(&mut scale)
.expect("ALERTA ALERTA ANTIFASCISTA");
@ -24,7 +24,13 @@ fn main() {
println!("Please enter a temperature");
io::stdin().read_line(&mut temperature)
.expect("ALERTA ALERTA ANTIFASCISTA");
let mut temperature: f32 = temperature.trim().parse().unwrap();
let mut temperature: f32 = match temperature.trim().parse() {
Ok(x) => x,
Err(_) => {
println!("Error: not recognised as a number, please try again.");
continue;
}
};
// [°C] = ([°F] - 32) x 5/9
//[°F] = [°C] x 9/5 + 32