mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-30 17:25:32 +00:00
Use internal scan
state in Result
s implementation
This commit is contained in:
parent
38de0bfd22
commit
ed248017b4
3 changed files with 6 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue