mirror of
https://github.com/async-rs/async-std.git
synced 2025-02-06 20:55:33 +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
|
// if a failure occurs
|
||||||
let mut found_error = None;
|
let mut found_error = None;
|
||||||
let out: V = stream
|
let out: V = stream
|
||||||
.scan((), |(), elem| {
|
.scan(&mut found_error, |error, elem| {
|
||||||
match elem {
|
match elem {
|
||||||
Ok(elem) => Some(elem),
|
Ok(elem) => Some(elem),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
found_error = Some(err);
|
**error = Some(err);
|
||||||
// Stop processing the stream on error
|
// Stop processing the stream on error
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ where
|
||||||
// Using `scan` here because it is able to stop the stream early
|
// Using `scan` here because it is able to stop the stream early
|
||||||
// if a failure occurs
|
// if a failure occurs
|
||||||
let mut found_error = None;
|
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 {
|
match elem {
|
||||||
Ok(elem) => Some(elem),
|
Ok(elem) => Some(elem),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
found_error = Some(err);
|
**error = Some(err);
|
||||||
// Stop processing the stream on error
|
// Stop processing the stream on error
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ where
|
||||||
// Using `scan` here because it is able to stop the stream early
|
// Using `scan` here because it is able to stop the stream early
|
||||||
// if a failure occurs
|
// if a failure occurs
|
||||||
let mut found_error = None;
|
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 {
|
match elem {
|
||||||
Ok(elem) => Some(elem),
|
Ok(elem) => Some(elem),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
found_error = Some(err);
|
**error = Some(err);
|
||||||
// Stop processing the stream on error
|
// Stop processing the stream on error
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue