2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-28 19:26:49 +00:00

fix type def

This commit is contained in:
k-nasa 2019-10-26 00:26:53 +09:00
parent 271b6f4a1c
commit 00e7e58bf3
2 changed files with 14 additions and 21 deletions

View file

@ -13,27 +13,27 @@ pin_project! {
/// [`flat_map`]: trait.Stream.html#method.flat_map /// [`flat_map`]: trait.Stream.html#method.flat_map
/// [`Stream`]: trait.Stream.html /// [`Stream`]: trait.Stream.html
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct FlatMap<S: Stream, U: IntoStream, F> { pub struct FlatMap<S, U, T, F> {
#[pin] #[pin]
inner: FlattenCompat<Map<S, F, S::Item, U>, U>, inner: FlattenCompat<Map<S, F, T, U>, U>,
} }
} }
impl<S, U, F> FlatMap<S, U, F> impl<S, U, F> FlatMap<S, U, S::Item, F>
where where
S: Stream, S: Stream,
U: IntoStream, U: IntoStream,
F: FnMut(S::Item) -> U, F: FnMut(S::Item) -> U,
{ {
pub fn new(stream: S, f: F) -> FlatMap<S, U, F> { pub fn new(stream: S, f: F) -> FlatMap<S, U, S::Item, F> {
FlatMap { FlatMap {
inner: FlattenCompat::new(stream.map(f)), inner: FlattenCompat::new(stream.map(f)),
} }
} }
} }
impl<S, U, F> Stream for FlatMap<S, U, F> impl<S, U, F> Stream for FlatMap<S, U, S::Item, F>
where where
S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin, S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin,
U: Stream + std::marker::Unpin, U: Stream + std::marker::Unpin,
@ -53,22 +53,19 @@ pin_project!{
/// [`flatten`]: trait.Stream.html#method.flatten /// [`flatten`]: trait.Stream.html#method.flatten
/// [`Stream`]: trait.Stream.html /// [`Stream`]: trait.Stream.html
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct Flatten<S: Stream> pub struct Flatten<S, U> {
where
S::Item: IntoStream,
{
#[pin] #[pin]
inner: FlattenCompat<S, <S::Item as IntoStream>::IntoStream>, inner: FlattenCompat<S, U>
} }
} }
impl<S: Stream<Item: IntoStream>> Flatten<S> { impl<S: Stream<Item: IntoStream>> Flatten<S, S::Item> {
pub fn new(stream: S) -> Flatten<S> { pub fn new(stream: S) -> Flatten<S, S::Item> {
Flatten { inner: FlattenCompat::new(stream) } Flatten { inner: FlattenCompat::new(stream) }
} }
} }
impl<S, U> Stream for Flatten<S> impl<S, U> Stream for Flatten<S, <S::Item as IntoStream>::IntoStream>
where where
S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin, S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin,
U: Stream + std::marker::Unpin, U: Stream + std::marker::Unpin,

View file

@ -30,6 +30,7 @@ mod filter;
mod filter_map; mod filter_map;
mod find; mod find;
mod find_map; mod find_map;
mod flatten;
mod fold; mod fold;
mod for_each; mod for_each;
mod fuse; mod fuse;
@ -77,6 +78,7 @@ use try_for_each::TryForEeachFuture;
pub use chain::Chain; pub use chain::Chain;
pub use filter::Filter; pub use filter::Filter;
pub use flatten::{FlatMap, Flatten};
pub use fuse::Fuse; pub use fuse::Fuse;
pub use inspect::Inspect; pub use inspect::Inspect;
pub use map::Map; pub use map::Map;
@ -99,10 +101,8 @@ cfg_unstable! {
use crate::stream::into_stream::IntoStream; use crate::stream::into_stream::IntoStream;
pub use merge::Merge; pub use merge::Merge;
pub use flatten::{FlatMap, Flatten};
mod merge; mod merge;
mod flatten;
} }
extension_trait! { extension_trait! {
@ -588,9 +588,7 @@ extension_trait! {
# }); # });
``` ```
"#] "#]
#[cfg(feature = "unstable")] fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, Self::Item, F>
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where where
Self: Sized, Self: Sized,
U: IntoStream, U: IntoStream,
@ -622,9 +620,7 @@ extension_trait! {
# }); # });
"#] "#]
#[cfg(feature = "unstable")] fn flatten(self) -> Flatten<Self, Self::Item>
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn flatten(self) -> Flatten<Self>
where where
Self: Sized, Self: Sized,
Self::Item: IntoStream, Self::Item: IntoStream,