mirror of
https://codeberg.org/unbeatable-101/FahrenheitToCelsius.git
synced 2024-06-19 07:17:09 +00:00
Version bump
This commit is contained in:
parent
d88885423e
commit
bae259b61c
|
@ -1,4 +1,4 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ftoc"
|
name = "ftoc"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -28,16 +28,20 @@ fn main() {
|
||||||
.read_line(&mut input)
|
.read_line(&mut input)
|
||||||
.expect("Failed to read line");
|
.expect("Failed to read line");
|
||||||
let input = input.trim();
|
let input = input.trim();
|
||||||
//Split the input into two strings, input: Contains the number
|
/*
|
||||||
//and system: Contains if it is celcius or fahrenheit
|
Split the input into two strings. Input, which contains the number;
|
||||||
|
and System, which contains if it is celcius or fahrenheit
|
||||||
|
*/
|
||||||
let (input,system) = input.split_at(input.len() - 1);
|
let (input,system) = input.split_at(input.len() - 1);
|
||||||
//If the input in a number, output it, else, restart loop
|
//If the input in a number, output it, else, restart loop
|
||||||
let input: f32 = match input.parse() {
|
let input: f32 = match input.parse() {
|
||||||
Ok(num) => num,
|
Ok(num) => num,
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
//If the system is know, call the convert function, else,
|
/*
|
||||||
//repeat loop
|
If the system is known, call the convert function,
|
||||||
|
otherwise repeat loop
|
||||||
|
*/
|
||||||
match system {
|
match system {
|
||||||
"C" => println!("{}°C is {:.2}°F", input, convert_to_f(input)),
|
"C" => println!("{}°C is {:.2}°F", input, convert_to_f(input)),
|
||||||
"F" => println!("{}°F is {:.2}°C", input, convert_to_c(input)),
|
"F" => println!("{}°F is {:.2}°C", input, convert_to_c(input)),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user