Skip to content

Commit 3760910

Browse files
authored
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 - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting N/A
1 parent 3c632e9 commit 3760910

10 files changed

Lines changed: 10 additions & 14 deletions

File tree

crates/nu-cmd-extra/src/extra/filters/each_while.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Command for EachWhile {
2525
)])
2626
.required(
2727
"closure",
28-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
28+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
2929
"the closure to run",
3030
)
3131
.category(Category::Filters)

crates/nu-command/src/filters/all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl Command for All {
1414
.input_output_types(vec![(Type::List(Box::new(Type::Any)), Type::Bool)])
1515
.required(
1616
"predicate",
17-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
17+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
1818
"A closure that must evaluate to a boolean.",
1919
)
2020
.category(Category::Filters)

crates/nu-command/src/filters/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl Command for Any {
1414
.input_output_types(vec![(Type::List(Box::new(Type::Any)), Type::Bool)])
1515
.required(
1616
"predicate",
17-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
17+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
1818
"A closure that must evaluate to a boolean.",
1919
)
2020
.category(Category::Filters)

crates/nu-command/src/filters/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ a variable. On the other hand, the "row condition" syntax is not supported."#
3030
])
3131
.required(
3232
"closure",
33-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
33+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
3434
"Predicate closure.",
3535
)
3636
.category(Category::Filters)

crates/nu-command/src/filters/par_each.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Command for ParEach {
3838
)
3939
.required(
4040
"closure",
41-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
41+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
4242
"The closure to run.",
4343
)
4444
.allow_variants_without_examples(true)

crates/nu-command/src/filters/reduce.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ impl Command for Reduce {
2424
)
2525
.required(
2626
"closure",
27-
SyntaxShape::Closure(Some(vec![
28-
SyntaxShape::Any,
29-
SyntaxShape::Any,
30-
SyntaxShape::Int,
31-
])),
27+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Any])),
3228
"Reducing function.",
3329
)
3430
.allow_variants_without_examples(true)

crates/nu-command/src/filters/skip/skip_until.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Command for SkipUntil {
2020
])
2121
.required(
2222
"predicate",
23-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
23+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
2424
"The predicate that skipped element must not match.",
2525
)
2626
.category(Category::Filters)

crates/nu-command/src/filters/skip/skip_while.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Command for SkipWhile {
2020
])
2121
.required(
2222
"predicate",
23-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
23+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
2424
"The predicate that skipped element must match.",
2525
)
2626
.category(Category::Filters)

crates/nu-command/src/filters/take/take_until.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Command for TakeUntil {
1717
)])
1818
.required(
1919
"predicate",
20-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
20+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
2121
"The predicate that element(s) must not match.",
2222
)
2323
.category(Category::Filters)

crates/nu-command/src/filters/take/take_while.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Command for TakeWhile {
2020
])
2121
.required(
2222
"predicate",
23-
SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Int])),
23+
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
2424
"The predicate that element(s) must match.",
2525
)
2626
.category(Category::Filters)

0 commit comments

Comments
 (0)