Skip to content

Conversation

@bluss
Copy link
Contributor

@bluss bluss commented Aug 12, 2013

Replace the remaining functions marked for issue #8228 with similar functions that are iterator-based.

Change either::{lefts, rights} to be iterator-filtering instead of returning a vector.

Replace map_vec, map_vec2, iter_vec2 in std::result with three functions:

  • result::collect gathers Iterator<Result<V, U>> to Result<~[V], U>
  • result::fold folds Iterator<Result<T, E>> to Result<V, E>
  • result::fold_ folds Iterator<Result<T, E>> to Result<(), E>

blake2-ppc added 3 commits August 13, 2013 16:20
Remove the only use of either::partition since it was better
accomplished with vector methods.

Update either::partition so that it sizes the vectors correctly before
it starts.
Replace these with three functions based on iterators: collect, fold,
and fold_. The mapping part is replaced by iterator .map(), so the part
that these functions do is to accumulate the final Result<,> value.

* `result::collect` gathers `Iterator<Result<V, U>>` to `Result<~[V], U>`
* `result::fold` folds `Iterator<Result<T, E>>` to `Result<V, E>`
* `result::fold_` folds `Iterator<Result<T, E>>` to `Result<(), E>`
@bluss
Copy link
Contributor Author

bluss commented Aug 13, 2013

Rebased to squash together some changes to the PR.

Keep either::partition anyway. Its only user was doing it wrong, but this function might still be useful.

@emberian
Copy link
Contributor

rollup candidate

@bluss bluss closed this Aug 14, 2013
@bluss bluss reopened this Aug 14, 2013
@bluss bluss closed this Aug 15, 2013
bors added a commit that referenced this pull request Aug 16, 2013
Retry of PR #8471

Replace the remaining functions marked for issue #8228 with similar functions that are iterator-based.

Change `either::{lefts, rights}` to be iterator-filtering instead of returning a vector.

Replace `map_vec`, `map_vec2`, `iter_vec2` in std::result with three functions:

* `result::collect` gathers `Iterator<Result<V, U>>` to `Result<~[V], U>`
* `result::fold` folds `Iterator<Result<T, E>>` to `Result<V, E>`
* `result::fold_` folds `Iterator<Result<T, E>>` to `Result<(), E>`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 14, 2022
new lint that detects useless match expression

fixes rust-lang#7040

changelog: Add new  lint [`needless_match`] under complexity lint group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants