From c14f8096148e8d203b98e3b0956cb1f668a7248b Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 2 Jun 2021 18:55:31 -0400 Subject: [PATCH] Fix clippy warnings --- src/calc/entries.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/calc/entries.rs b/src/calc/entries.rs index eb8d12e..cd75ae6 100644 --- a/src/calc/entries.rs +++ b/src/calc/entries.rs @@ -37,14 +37,14 @@ pub enum VectorDirection { } impl VectorDirection { - pub fn swap(&self) -> Self { + pub const fn swap(&self) -> Self { match self { Self::Row => Self::Column, Self::Column => Self::Row, } } - pub fn get_separator(&self) -> &str { + pub const fn get_separator(&self) -> &str { match self { Self::Row => " ", Self::Column => "; ", @@ -333,10 +333,10 @@ impl CalculatorEntry for Vector { .try_fold(Entry::Number(Number::ZERO), |acc, n2| { acc.add(&n2.pow_num(&Number { value: 2.0_f64 })?) })?; - Ok(value.sqrt()?) + value.sqrt() } fn inverse(&self) -> CalculatorResult { - Ok(Entry::Vector(Vector { + Ok(Entry::Vector(Self { values: self.values.clone(), direction: self.direction.swap(), })) @@ -607,7 +607,7 @@ impl CalculatorEntry for Number { value: match angle_mode { CalculatorAngleMode::Degrees => self.value.asin().to_degrees(), CalculatorAngleMode::Radians => self.value.asin(), - CalculatorAngleMode::Grads => self.value.asin() * std::f64::consts::PI / 200.0, + CalculatorAngleMode::Grads => self.value.asin() * 200.0 / std::f64::consts::PI, }, })) } @@ -616,7 +616,7 @@ impl CalculatorEntry for Number { value: match angle_mode { CalculatorAngleMode::Degrees => self.value.acos().to_degrees(), CalculatorAngleMode::Radians => self.value.acos(), - CalculatorAngleMode::Grads => self.value.acos() * std::f64::consts::PI / 200.0, + CalculatorAngleMode::Grads => self.value.acos() * 200.0 / std::f64::consts::PI, }, })) } @@ -625,7 +625,7 @@ impl CalculatorEntry for Number { value: match angle_mode { CalculatorAngleMode::Degrees => self.value.atan().to_degrees(), CalculatorAngleMode::Radians => self.value.atan(), - CalculatorAngleMode::Grads => self.value.atan() * std::f64::consts::PI / 200.0, + CalculatorAngleMode::Grads => self.value.atan() * 200.0 / std::f64::consts::PI, }, })) }