diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index a3ab5fbbd8..d20978222c 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -29,6 +29,10 @@ impl Command for SubCommand { vec!["square", "root"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -44,6 +48,23 @@ impl Command for SubCommand { input.map(move |value| operate(value, head), engine_state.signals()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let head = call.head; + // This doesn't match explicit nulls + if matches!(input, PipelineData::Empty) { + return Err(ShellError::PipelineEmpty { dst_span: head }); + } + input.map( + move |value| operate(value, head), + working_set.permanent().signals(), + ) + } + fn examples(&self) -> Vec { vec![Example { description: "Compute the square root of each number in a list",