Fix clippy warnings

This commit is contained in:
Austen Adler 2021-06-02 18:55:31 -04:00
parent e3b5457fe6
commit c14f809614

View File

@ -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<Entry> {
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,
},
}))
}