Skip to content

Commit 00e7e58

Browse files
committed
fix type def
1 parent 271b6f4 commit 00e7e58

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

src/stream/stream/flatten.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ pin_project! {
1313
/// [`flat_map`]: trait.Stream.html#method.flat_map
1414
/// [`Stream`]: trait.Stream.html
1515
#[allow(missing_debug_implementations)]
16-
pub struct FlatMap<S: Stream, U: IntoStream, F> {
16+
pub struct FlatMap<S, U, T, F> {
1717
#[pin]
18-
inner: FlattenCompat<Map<S, F, S::Item, U>, U>,
18+
inner: FlattenCompat<Map<S, F, T, U>, U>,
1919
}
2020
}
2121

22-
impl<S, U, F> FlatMap<S, U, F>
22+
impl<S, U, F> FlatMap<S, U, S::Item, F>
2323
where
2424
S: Stream,
2525
U: IntoStream,
2626
F: FnMut(S::Item) -> U,
2727
{
2828

29-
pub fn new(stream: S, f: F) -> FlatMap<S, U, F> {
29+
pub fn new(stream: S, f: F) -> FlatMap<S, U, S::Item, F> {
3030
FlatMap {
3131
inner: FlattenCompat::new(stream.map(f)),
3232
}
3333
}
3434
}
3535

36-
impl<S, U, F> Stream for FlatMap<S, U, F>
36+
impl<S, U, F> Stream for FlatMap<S, U, S::Item, F>
3737
where
3838
S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin,
3939
U: Stream + std::marker::Unpin,
@@ -53,22 +53,19 @@ pin_project!{
5353
/// [`flatten`]: trait.Stream.html#method.flatten
5454
/// [`Stream`]: trait.Stream.html
5555
#[allow(missing_debug_implementations)]
56-
pub struct Flatten<S: Stream>
57-
where
58-
S::Item: IntoStream,
59-
{
56+
pub struct Flatten<S, U> {
6057
#[pin]
61-
inner: FlattenCompat<S, <S::Item as IntoStream>::IntoStream>,
58+
inner: FlattenCompat<S, U>
6259
}
6360
}
6461

65-
impl<S: Stream<Item: IntoStream>> Flatten<S> {
66-
pub fn new(stream: S) -> Flatten<S> {
62+
impl<S: Stream<Item: IntoStream>> Flatten<S, S::Item> {
63+
pub fn new(stream: S) -> Flatten<S, S::Item> {
6764
Flatten { inner: FlattenCompat::new(stream) }
6865
}
6966
}
7067

71-
impl<S, U> Stream for Flatten<S>
68+
impl<S, U> Stream for Flatten<S, <S::Item as IntoStream>::IntoStream>
7269
where
7370
S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin,
7471
U: Stream + std::marker::Unpin,

src/stream/stream/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mod filter;
3030
mod filter_map;
3131
mod find;
3232
mod find_map;
33+
mod flatten;
3334
mod fold;
3435
mod for_each;
3536
mod fuse;
@@ -77,6 +78,7 @@ use try_for_each::TryForEeachFuture;
7778

7879
pub use chain::Chain;
7980
pub use filter::Filter;
81+
pub use flatten::{FlatMap, Flatten};
8082
pub use fuse::Fuse;
8183
pub use inspect::Inspect;
8284
pub use map::Map;
@@ -99,10 +101,8 @@ cfg_unstable! {
99101
use crate::stream::into_stream::IntoStream;
100102

101103
pub use merge::Merge;
102-
pub use flatten::{FlatMap, Flatten};
103104

104105
mod merge;
105-
mod flatten;
106106
}
107107

108108
extension_trait! {
@@ -588,9 +588,7 @@ extension_trait! {
588588
# });
589589
```
590590
"#]
591-
#[cfg(feature = "unstable")]
592-
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
593-
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
591+
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, Self::Item, F>
594592
where
595593
Self: Sized,
596594
U: IntoStream,
@@ -622,9 +620,7 @@ extension_trait! {
622620
623621
# });
624622
"#]
625-
#[cfg(feature = "unstable")]
626-
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
627-
fn flatten(self) -> Flatten<Self>
623+
fn flatten(self) -> Flatten<Self, Self::Item>
628624
where
629625
Self: Sized,
630626
Self::Item: IntoStream,

0 commit comments

Comments
 (0)