feat: apply the --numbered
option to acc in reduce
command.
#5575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The idea for this PR comes from the
commands::reduce::reduce_numbered_example
test in #4314.I was curious about the
--numbered
option ofreduce
after seeing the following tests:One of the reasons this test cannot work is that the types returned by
it
andacc
are different.Currently, the
-n
option converts only theit
argument to a block containing an index.This is why, in other examples, the
item
property is accessed only in theit
.It is a little bit different to the regular
reduce
provided in other languages.So I modified the
-n
option to apply to bothacc
andit
.In this case, the test will get the result we expect if we change it like this:
Of course, this is a proposal. So, the related tests and examples have not been updated yet.
If we can come to an agreement on this, I will update the rest of the content, including the tests.
Tests
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace --features=extra
to check that all the tests pass