2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-30 17:25:32 +00:00

Use internal scan state in Results implementation

This commit is contained in:
Oleg Nosov 2020-01-15 12:06:50 +03:00
parent 38de0bfd22
commit ed248017b4
No known key found for this signature in database
GPG key ID: DE90B83800644E24
3 changed files with 6 additions and 6 deletions

View file

@ -21,11 +21,11 @@ where
// if a failure occurs
let mut found_error = None;
let out: V = stream
.scan((), |(), elem| {
.scan(&mut found_error, |error, elem| {
match elem {
Ok(elem) => Some(elem),
Err(err) => {
found_error = Some(err);
**error = Some(err);
// Stop processing the stream on error
None
}

View file

@ -43,11 +43,11 @@ where
// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_error = None;
let out = <T as Product<U>>::product(stream.scan((), |(), elem| {
let out = <T as Product<U>>::product(stream.scan(&mut found_error, |error, elem| {
match elem {
Ok(elem) => Some(elem),
Err(err) => {
found_error = Some(err);
**error = Some(err);
// Stop processing the stream on error
None
}

View file

@ -43,11 +43,11 @@ where
// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_error = None;
let out = <T as Sum<U>>::sum(stream.scan((), |(), elem| {
let out = <T as Sum<U>>::sum(stream.scan(&mut found_error, |error, elem| {
match elem {
Ok(elem) => Some(elem),
Err(err) => {
found_error = Some(err);
**error = Some(err);
// Stop processing the stream on error
None
}