From 1065d024dde5fcea477978dc700994f89f4a108c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 14 Jan 2021 17:12:11 +0100 Subject: [PATCH] =?UTF-8?q?fix=20spelling:=20Celcius=20=E2=86=92=20Celsius?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/lexer.rs | 2 +- src/lib.rs | 4 ++-- src/main.rs | 2 +- src/units.rs | 20 ++++++++++---------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 814dec5..feacf28 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ cpc = "1.*" use cpc::{eval}; use cpc::units::Unit; -match eval("3m + 1cm", true, Unit::Celcius, false) { +match eval("3m + 1cm", true, Unit::Celsius, false) { Ok(answer) => { // answer: Number { value: 301, unit: Unit::Centimeter } println!("Evaluated value: {} {:?}", answer.value, answer.unit) diff --git a/src/lexer.rs b/src/lexer.rs index 301dfd4..8d5ab25 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -385,7 +385,7 @@ pub fn lex(input: &str, allow_trailing_operators: bool, default_degree: Unit) -> "kn" | "kt" | "knot" | "knots" => tokens.push(Token::Unit(Knot)), "k" | "kelvin" | "kelvins" => tokens.push(Token::Unit(Kelvin)), - "c" | "celcius" => tokens.push(Token::Unit(Celcius)), + "c" | "celsius" => tokens.push(Token::Unit(Celsius)), "f" | "fahrenheit" | "fahrenheits" => tokens.push(Token::Unit(Fahrenheit)), "deg" | "degree" | "degrees" => tokens.push(Token::Unit(default_degree)), diff --git a/src/lib.rs b/src/lib.rs index d8903f9..9e86159 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //! use cpc::{eval}; //! use cpc::units::Unit; //! -//! match eval("3m + 1cm", true, Unit::Celcius, false) { +//! match eval("3m + 1cm", true, Unit::Celsius, false) { //! Ok(answer) => { //! // answer: Number { value: 301, unit: Unit::Centimeter } //! println!("Evaluated value: {} {:?}", answer.value, answer.unit) @@ -201,7 +201,7 @@ pub type TokenVector = Vec; /// use cpc::{eval}; /// use cpc::units::Unit; /// -/// match eval("3m + 1cm", true, Unit::Celcius, false) { +/// match eval("3m + 1cm", true, Unit::Celsius, false) { /// Ok(answer) => { /// // answer: Number { value: 301, unit: Unit::Centimeter } /// println!("Evaluated value: {} {:?}", answer.value, answer.unit) diff --git a/src/main.rs b/src/main.rs index 0c37be1..772ab52 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ fn main() { debug = true; } if args.len() >= 2 { - match eval(&args[1], true, Unit::Celcius, debug) { + match eval(&args[1], true, Unit::Celsius, debug) { Ok(answer) => { if !debug { println!("{} {:?}", answer.value, answer.unit) diff --git a/src/units.rs b/src/units.rs index 9c81561..26f1e41 100644 --- a/src/units.rs +++ b/src/units.rs @@ -258,7 +258,7 @@ create_units!( Knot: (Speed, d128!(1.852)), Kelvin: (Temperature, d128!(0)), - Celcius: (Temperature, d128!(0)), + Celsius: (Temperature, d128!(0)), Fahrenheit: (Temperature, d128!(0)), ); @@ -303,14 +303,14 @@ pub fn convert(number: Number, to_unit: Unit) -> Result { if number.unit.category() == UnitType::Temperature { match (number.unit, to_unit) { (Kelvin, Kelvin) => ok(value), - (Kelvin, Celcius) => ok(value-d128!(273.15)), + (Kelvin, Celsius) => ok(value-d128!(273.15)), (Kelvin, Fahrenheit) => ok(value*d128!(1.8)-d128!(459.67)), - (Celcius, Celcius) => ok(value), - (Celcius, Kelvin) => ok(value+d128!(273.15)), - (Celcius, Fahrenheit) => ok(value*d128!(1.8)+d128!(32)), + (Celsius, Celsius) => ok(value), + (Celsius, Kelvin) => ok(value+d128!(273.15)), + (Celsius, Fahrenheit) => ok(value*d128!(1.8)+d128!(32)), (Fahrenheit, Fahrenheit) => ok(value), (Fahrenheit, Kelvin) => ok((value+d128!(459.67))*d128!(5)/d128!(9)), - (Fahrenheit, Celcius) => ok((value-d128!(32))/d128!(1.8)), + (Fahrenheit, Celsius) => ok((value-d128!(32))/d128!(1.8)), _ => Err(format!("Error converting temperature {:?} to {:?}", number.unit, to_unit)), } } else { @@ -865,11 +865,11 @@ mod tests { assert_eq!(convert_test(1.609344, KilometersPerHour, MilesPerHour), 1.0); assert_eq!(convert_test(1.852, KilometersPerHour, Knot), 1.0); - assert_eq!(convert_test(274.15, Kelvin, Celcius), 1.0); + assert_eq!(convert_test(274.15, Kelvin, Celsius), 1.0); assert_eq!(convert_test(300.0, Kelvin, Fahrenheit), 80.33); - assert_eq!(convert_test(-272.15, Celcius, Kelvin), 1.0); - assert_eq!(convert_test(-15.0, Celcius, Fahrenheit), 5.0); + assert_eq!(convert_test(-272.15, Celsius, Kelvin), 1.0); + assert_eq!(convert_test(-15.0, Celsius, Fahrenheit), 5.0); assert_eq!(convert_test(80.33, Fahrenheit, Kelvin), 300.0); - assert_eq!(convert_test(5.0, Fahrenheit, Celcius), -15.0); + assert_eq!(convert_test(5.0, Fahrenheit, Celsius), -15.0); } }