From cf8d218b11d5b5940ddea8639252f5524a3b1e0e Mon Sep 17 00:00:00 2001 From: electria Date: Thu, 16 Jul 2026 10:53:49 -0700 Subject: [PATCH] refactor: use compiler builtin constant for pi as per clippy lint --- src/nodes/from_str.rs | 3 ++- src/nodes/tests.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nodes/from_str.rs b/src/nodes/from_str.rs index f4b147d..b2d6535 100644 --- a/src/nodes/from_str.rs +++ b/src/nodes/from_str.rs @@ -1,3 +1,4 @@ +use core::f64; use std::str::FromStr; use rug::{Float, float::ParseFloatError, ops::CompleteRound}; @@ -9,7 +10,7 @@ impl Node { Ok(match s { "c" => Self::Number(Float::with_val(PREC, 299_792_458)), "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()?), }) } diff --git a/src/nodes/tests.rs b/src/nodes/tests.rs index 81c2ab9..ae50576 100644 --- a/src/nodes/tests.rs +++ b/src/nodes/tests.rs @@ -1,3 +1,4 @@ +use core::f64; use std::str::FromStr; use rug::Float; @@ -24,7 +25,7 @@ fn constants() { ); assert_eq!( Nodes::from_str("pi").unwrap().evaluate().to_f64(), - 3.1415926536 + f64::consts::PI ); }