,
- __to: PhantomData,
}
}
-impl Map {
+impl Map {
pub(crate) fn new(stream: S, f: F) -> Self {
Map {
stream,
f,
- __from: PhantomData,
- __to: PhantomData,
}
}
}
-impl Stream for Map
+impl Stream for Map
where
S: Stream,
F: FnMut(S::Item) -> B,
diff --git a/src/stream/stream/mod.rs b/src/stream/stream/mod.rs
index 8ea1459..5756a21 100644
--- a/src/stream/stream/mod.rs
+++ b/src/stream/stream/mod.rs
@@ -288,6 +288,7 @@ extension_trait! {
Creates a stream that yields elements based on a predicate.
# Examples
+
```
# fn main() { async_std::task::block_on(async {
#
@@ -300,12 +301,11 @@ extension_trait! {
assert_eq!(s.next().await, Some(1));
assert_eq!(s.next().await, Some(2));
assert_eq!(s.next().await, None);
-
#
# }) }
```
"#]
- fn take_while(self, predicate: P) -> TakeWhile
+ fn take_while(self, predicate: P) -> TakeWhile
where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
@@ -410,10 +410,10 @@ extension_trait! {
# }) }
```
"#]
- fn cloned<'a,T>(self) -> Cloned
+ fn cloned<'a, T>(self) -> Cloned
where
Self: Sized + Stream- ,
- T : 'a + Clone,
+ T: Clone + 'a,
{
Cloned::new(self)
}
@@ -443,10 +443,10 @@ extension_trait! {
# }) }
```
"#]
- fn copied<'a,T>(self) -> Copied
+ fn copied<'a, T>(self) -> Copied
where
Self: Sized + Stream
- ,
- T : 'a + Copy,
+ T: Copy + 'a,
{
Copied::new(self)
}
@@ -475,10 +475,9 @@ extension_trait! {
# })
```
"#]
- fn cycle(self) -> Cycle
- where
- Self: Sized,
- Self::Item: Clone,
+ fn cycle(self) -> Cycle
+ where
+ Self: Clone + Sized,
{
Cycle::new(self)
}
@@ -505,7 +504,6 @@ extension_trait! {
assert_eq!(s.next().await, Some((1, 'b')));
assert_eq!(s.next().await, Some((2, 'c')));
assert_eq!(s.next().await, None);
-
#
# }) }
```
@@ -540,7 +538,7 @@ extension_trait! {
# }) }
```
"#]
- fn map(self, f: F) -> Map
+ fn map(self, f: F) -> Map
where
Self: Sized,
F: FnMut(Self::Item) -> B,
@@ -565,17 +563,18 @@ extension_trait! {
let s = stream::from_iter(vec![1, 2, 3, 4, 5]);
let sum = s
- .inspect(|x| println!("about to filter {}", x))
- .filter(|x| x % 2 == 0)
- .inspect(|x| println!("made it through filter: {}", x))
- .fold(0, |sum, i| sum + i).await;
+ .inspect(|x| println!("about to filter {}", x))
+ .filter(|x| x % 2 == 0)
+ .inspect(|x| println!("made it through filter: {}", x))
+ .fold(0, |sum, i| sum + i)
+ .await;
assert_eq!(sum, 6);
#
# }) }
```
"#]
- fn inspect(self, f: F) -> Inspect
+ fn inspect(self, f: F) -> Inspect
where
Self: Sized,
F: FnMut(&Self::Item),
@@ -618,7 +617,6 @@ extension_trait! {
#
# }) }
```
-
"#]
fn last(
self,
@@ -685,7 +683,7 @@ extension_trait! {
# }) }
```
"#]
- fn filter
(self, predicate: P) -> Filter
+ fn filter(self, predicate: P) -> Filter
where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
@@ -721,7 +719,7 @@ extension_trait! {
"#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
- fn flat_map(self, f: F) -> FlatMap
+ fn flat_map(self, f: F) -> FlatMap
where
Self: Sized,
U: IntoStream,
@@ -755,7 +753,7 @@ extension_trait! {
"#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
- fn flatten(self) -> Flatten
+ fn flatten(self) -> Flatten
where
Self: Sized,
Self::Item: IntoStream,
@@ -796,7 +794,7 @@ extension_trait! {
# }) }
```
"#]
- fn filter_map(self, f: F) -> FilterMap
+ fn filter_map(self, f: F) -> FilterMap
where
Self: Sized,
F: FnMut(Self::Item) -> Option,
@@ -804,7 +802,7 @@ extension_trait! {
FilterMap::new(self, f)
}
- #[doc = r#"
+ #[doc = r#"
Returns the element that gives the minimum value with respect to the
specified key function. If several elements are equally minimum,
the first element is returned. If the stream is empty, `None` is returned.
@@ -828,19 +826,19 @@ extension_trait! {
# }) }
```
"#]
- fn min_by_key(
+ fn min_by_key(
self,
- key_by: K,
- ) -> impl Future