Skip to content

Commit 5ba2539

Browse files
committed
FromStream for ()
1 parent 98c79f4 commit 5ba2539

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ cfg_if! {
6565
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
6666
pub mod pin;
6767

68+
mod unit;
6869
mod vec;
6970
mod result;
7071
mod option;

src/unit/from_stream.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use std::pin::Pin;
2+
3+
use crate::prelude::*;
4+
use crate::stream::{FromStream, IntoStream};
5+
6+
impl FromStream<()> for () {
7+
#[inline]
8+
fn from_stream<'a, S: IntoStream<Item = ()>>(
9+
stream: S,
10+
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
11+
where
12+
<S as IntoStream>::IntoStream: 'a,
13+
{
14+
Box::pin(stream.into_stream().for_each(|_| ()))
15+
}
16+
}

src/unit/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! The Rust primitive `()` type, sometimes called "unit" or "nil".
2+
//!
3+
//! This module provides types and implementations for working
4+
//! asynchronously with values of type `()`.
5+
6+
mod from_stream;

0 commit comments

Comments
 (0)