diff --git a/src/lib.rs b/src/lib.rs index f64fdbc..3b0aa69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,6 +65,7 @@ cfg_if! { #[cfg_attr(feature = "docs", doc(cfg(unstable)))] pub mod pin; + mod unit; mod vec; mod result; mod option; diff --git a/src/unit/from_stream.rs b/src/unit/from_stream.rs new file mode 100644 index 0000000..a238982 --- /dev/null +++ b/src/unit/from_stream.rs @@ -0,0 +1,16 @@ +use std::pin::Pin; + +use crate::prelude::*; +use crate::stream::{FromStream, IntoStream}; + +impl FromStream<()> for () { + #[inline] + fn from_stream<'a, S: IntoStream>( + stream: S, + ) -> Pin + 'a>> + where + ::IntoStream: 'a, + { + Box::pin(stream.into_stream().for_each(|_| ())) + } +} diff --git a/src/unit/mod.rs b/src/unit/mod.rs new file mode 100644 index 0000000..cb8063d --- /dev/null +++ b/src/unit/mod.rs @@ -0,0 +1,6 @@ +//! The Rust primitive `()` type, sometimes called "unit" or "nil". +//! +//! This module provides types and implementations for working +//! asynchronously with values of type `()`. + +mod from_stream;