Skip to content

Commit 5f36061

Browse files
committed
temp solution until constants are part of std: rust-lang/rust#103883
1 parent 0329890 commit 5f36061

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/nu-command/src/math/egamma.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use nu_protocol::{
44
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
55
};
66

7+
/// The Euler-Mascheroni constant (γ)
8+
pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64;
9+
710
#[derive(Clone)]
811
pub struct SubCommand;
912

@@ -42,7 +45,8 @@ impl Command for SubCommand {
4245
call: &Call,
4346
_input: PipelineData,
4447
) -> Result<PipelineData, ShellError> {
45-
Ok(Value::float(std::f64::consts::EGAMMA, call.head).into_pipeline_data())
48+
// TODO: replace with std::f64::consts::EGAMMA when available https://github.com/rust-lang/rust/issues/103883
49+
Ok(Value::float(EGAMMA, call.head).into_pipeline_data())
4650
}
4751
}
4852

crates/nu-command/src/math/phi.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use nu_protocol::engine::{Command, EngineState, Stack};
33
use nu_protocol::{
44
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
55
};
6+
/// The golden ratio (φ)
7+
pub const PHI: f64 = 1.618033988749894848204586834365638118_f64;
68

79
#[derive(Clone)]
810
pub struct SubCommand;
@@ -42,7 +44,8 @@ impl Command for SubCommand {
4244
call: &Call,
4345
_input: PipelineData,
4446
) -> Result<PipelineData, ShellError> {
45-
Ok(Value::float(std::f64::consts::PHI, call.head).into_pipeline_data())
47+
// TODO: replace with std::f64::consts::PHI when available https://github.com/rust-lang/rust/issues/103883
48+
Ok(Value::float(PHI, call.head).into_pipeline_data())
4649
}
4750
}
4851

0 commit comments

Comments
 (0)