diff --git a/src/lib.rs b/src/lib.rs index 76ea9c40..dfa9a07a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,11 +48,11 @@ pub mod io; pub mod net; pub mod os; pub mod prelude; +mod result; pub mod stream; pub mod sync; pub mod task; mod vec; -mod result; #[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg(feature = "unstable")] diff --git a/src/result/from_stream.rs b/src/result/from_stream.rs index f74d06d6..71cf61dc 100644 --- a/src/result/from_stream.rs +++ b/src/result/from_stream.rs @@ -3,7 +3,9 @@ use crate::stream::{FromStream, IntoStream, Stream}; use std::pin::Pin; impl FromStream> for Result - where V: FromStream { +where + V: FromStream, +{ /// Takes each element in the stream: if it is an `Err`, no further /// elements are taken, and the `Err` is returned. Should no `Err` /// occur, a container with the values of each `Result` is returned. @@ -22,16 +24,19 @@ impl FromStream> for Result // Using `scan` here because it is able to stop the stream early // if a failure occurs let mut found_error = None; - let out: V = stream.scan((), |_, elem| { - match elem { - Ok(elem) => Some(elem), - Err(err) => { - found_error = Some(err); - // Stop processing the stream on error - None - }, - } - }).collect().await; + let out: V = stream + .scan((), |_, elem| { + match elem { + Ok(elem) => Some(elem), + Err(err) => { + found_error = Some(err); + // Stop processing the stream on error + None + } + } + }) + .collect() + .await; match found_error { Some(err) => Err(err), @@ -40,4 +45,3 @@ impl FromStream> for Result })) } } -