Skip to content

Implement partition_result#511

Merged
bors[bot] merged 1 commit intorust-itertools:masterfrom
mingyli:partition-result
Jan 16, 2021
Merged

Implement partition_result#511
bors[bot] merged 1 commit intorust-itertools:masterfrom
mingyli:partition-result

Conversation

@mingyli
Copy link
Contributor

@mingyli mingyli commented Jan 1, 2021

Addresses #510

partition_result behaves as OCaml Base's partition_result does:

use itertools::Itertools;

let successes_and_failures = vec![Ok(1), Err(false), Err(true), Ok(2)];

let (successes, failures): (Vec<_>, Vec<_>) = successes_and_failures
    .into_iter()
    .partition_result();

assert_eq!(successes, [1, 2]);
assert_eq!(failures, [false, true]);

@jswrenn jswrenn added this to the next milestone Jan 16, 2021
Copy link
Member

@jswrenn jswrenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 16, 2021

Build succeeded:

@bors bors bot merged commit 2d52ca2 into rust-itertools:master Jan 16, 2021
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.

2 participants