From 3760910f0bbf58e25787ee685046cd2837924882 Mon Sep 17 00:00:00 2001 From: Bahex Date: Mon, 16 Dec 2024 00:27:13 +0300 Subject: [PATCH] remove the deprecated index argument from filter commands' closure signature (#14594) # Description A lot of filter commands that have a closure argument (`each`, `filter`, etc), have a wrong signature for the closure, indicating an extra int argument for the closure. I think they are a left over from before `enumerate` was added, used to access iteration index. None of the commands changed in this PR actually supply this int argument. # User-Facing Changes N/A # Tests + Formatting - :green_circle: toolkit fmt - :green_circle: toolkit clippy - :green_circle: toolkit test - :green_circle: toolkit test stdlib # After Submitting N/A --- crates/nu-cmd-extra/src/extra/filters/each_while.rs | 2 +- crates/nu-command/src/filters/all.rs | 2 +- crates/nu-command/src/filters/any.rs | 2 +- crates/nu-command/src/filters/filter.rs | 2 +- crates/nu-command/src/filters/par_each.rs | 2 +- crates/nu-command/src/filters/reduce.rs | 6 +----- crates/nu-command/src/filters/skip/skip_until.rs | 2 +- crates/nu-command/src/filters/skip/skip_while.rs | 2 +- crates/nu-command/src/filters/take/take_until.rs | 2 +- crates/nu-command/src/filters/take/take_while.rs | 2 +- 10 files changed, 10 insertions(+), 14 deletions(-) diff --git a/crates/nu-cmd-extra/src/extra/filters/each_while.rs b/crates/nu-cmd-extra/src/extra/filters/each_while.rs index 67f0cc9482..cc5c066185 100644 --- a/crates/nu-cmd-extra/src/extra/filters/each_while.rs +++ b/crates/nu-cmd-extra/src/extra/filters/each_while.rs @@ -25,7 +25,7 @@ impl Command for EachWhile { )]) .required( "closure", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "the closure to run", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/all.rs b/crates/nu-command/src/filters/all.rs index e4ffdf2c87..aa36118273 100644 --- a/crates/nu-command/src/filters/all.rs +++ b/crates/nu-command/src/filters/all.rs @@ -14,7 +14,7 @@ impl Command for All { .input_output_types(vec![(Type::List(Box::new(Type::Any)), Type::Bool)]) .required( "predicate", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "A closure that must evaluate to a boolean.", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/any.rs b/crates/nu-command/src/filters/any.rs index cd8a6b65e4..230a96ebe7 100644 --- a/crates/nu-command/src/filters/any.rs +++ b/crates/nu-command/src/filters/any.rs @@ -14,7 +14,7 @@ impl Command for Any { .input_output_types(vec![(Type::List(Box::new(Type::Any)), Type::Bool)]) .required( "predicate", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "A closure that must evaluate to a boolean.", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/filter.rs b/crates/nu-command/src/filters/filter.rs index 93fe5a6e6d..ea7960c4d3 100644 --- a/crates/nu-command/src/filters/filter.rs +++ b/crates/nu-command/src/filters/filter.rs @@ -30,7 +30,7 @@ a variable. On the other hand, the "row condition" syntax is not supported."# ]) .required( "closure", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "Predicate closure.", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/par_each.rs b/crates/nu-command/src/filters/par_each.rs index fc0da7d3d3..4e4d526657 100644 --- a/crates/nu-command/src/filters/par_each.rs +++ b/crates/nu-command/src/filters/par_each.rs @@ -38,7 +38,7 @@ impl Command for ParEach { ) .required( "closure", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "The closure to run.", ) .allow_variants_without_examples(true) diff --git a/crates/nu-command/src/filters/reduce.rs b/crates/nu-command/src/filters/reduce.rs index 8aa77719b9..9d17339d0e 100644 --- a/crates/nu-command/src/filters/reduce.rs +++ b/crates/nu-command/src/filters/reduce.rs @@ -24,11 +24,7 @@ impl Command for Reduce { ) .required( "closure", - SyntaxShape::Closure(Some(vec![ - SyntaxShape::Any, - SyntaxShape::Any, - SyntaxShape::Int, - ])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Any])), "Reducing function.", ) .allow_variants_without_examples(true) diff --git a/crates/nu-command/src/filters/skip/skip_until.rs b/crates/nu-command/src/filters/skip/skip_until.rs index b73c817e9b..6f9ada280c 100644 --- a/crates/nu-command/src/filters/skip/skip_until.rs +++ b/crates/nu-command/src/filters/skip/skip_until.rs @@ -20,7 +20,7 @@ impl Command for SkipUntil { ]) .required( "predicate", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "The predicate that skipped element must not match.", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/skip/skip_while.rs b/crates/nu-command/src/filters/skip/skip_while.rs index 9423915242..494cf91558 100644 --- a/crates/nu-command/src/filters/skip/skip_while.rs +++ b/crates/nu-command/src/filters/skip/skip_while.rs @@ -20,7 +20,7 @@ impl Command for SkipWhile { ]) .required( "predicate", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "The predicate that skipped element must match.", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/take/take_until.rs b/crates/nu-command/src/filters/take/take_until.rs index e1dcd6ceda..4e8f38a3d2 100644 --- a/crates/nu-command/src/filters/take/take_until.rs +++ b/crates/nu-command/src/filters/take/take_until.rs @@ -17,7 +17,7 @@ impl Command for TakeUntil { )]) .required( "predicate", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "The predicate that element(s) must not match.", ) .category(Category::Filters) diff --git a/crates/nu-command/src/filters/take/take_while.rs b/crates/nu-command/src/filters/take/take_while.rs index 54e9384cba..c9e218f543 100644 --- a/crates/nu-command/src/filters/take/take_while.rs +++ b/crates/nu-command/src/filters/take/take_while.rs @@ -20,7 +20,7 @@ impl Command for TakeWhile { ]) .required( "predicate", - SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])), + SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), "The predicate that element(s) must match.", ) .category(Category::Filters)