refactor: use compiler builtin constant for pi
as per clippy lint
This commit is contained in:
parent
ae0f2a3aaf
commit
cf8d218b11
2 changed files with 4 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
use core::f64;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use rug::{Float, float::ParseFloatError, ops::CompleteRound};
|
use rug::{Float, float::ParseFloatError, ops::CompleteRound};
|
||||||
|
|
@ -9,7 +10,7 @@ impl Node {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
"c" => Self::Number(Float::with_val(PREC, 299_792_458)),
|
"c" => Self::Number(Float::with_val(PREC, 299_792_458)),
|
||||||
"A" => Self::Number(Float::with_val(PREC, 6.02214076e23)),
|
"A" => Self::Number(Float::with_val(PREC, 6.02214076e23)),
|
||||||
"pi" => Self::Number(Float::with_val(PREC, 3.1415926536)),
|
"pi" => Self::Number(Float::with_val(PREC, f64::consts::PI)),
|
||||||
_ => Self::Function(s.parse()?),
|
_ => Self::Function(s.parse()?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use core::f64;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use rug::Float;
|
use rug::Float;
|
||||||
|
|
@ -24,7 +25,7 @@ fn constants() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Nodes::from_str("pi").unwrap().evaluate().to_f64(),
|
Nodes::from_str("pi").unwrap().evaluate().to_f64(),
|
||||||
3.1415926536
|
f64::consts::PI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue