From 0576794e749519c2e36e76f01a29d928b1bad24d Mon Sep 17 00:00:00 2001 From: Bahex Date: Tue, 30 Jul 2024 16:51:51 +0300 Subject: [PATCH] reduce: supply to the closure as pipeline input as well (#13461) resolve #13459 # Description Make `reduce` supply the accumulator value to closure as pipeline input. # User-Facing Changes Mostly described in #13459 - Should not be a breaking change. - Allows cleaner patterns like `... | reduce {|it| merge $it}` # Tests + Formatting `cargo test --package nu-cli --test main -- commands::reduce` and `toolkit test stdlib` report no issues --- crates/nu-command/src/filters/reduce.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/nu-command/src/filters/reduce.rs b/crates/nu-command/src/filters/reduce.rs index 824e7709e5..4fca1df3a4 100644 --- a/crates/nu-command/src/filters/reduce.rs +++ b/crates/nu-command/src/filters/reduce.rs @@ -120,8 +120,7 @@ impl Command for Reduce { engine_state.signals().check(head)?; acc = closure .add_arg(value) - .add_arg(acc) - .run_with_input(PipelineData::Empty)? + .run_with_value(acc)? .into_value(head)?; }