Skip to content

Commit 5f67420

Browse files
committed
Revert "Adds latest version of relevant files"
This reverts commit aaf2638.
1 parent bfea84a commit 5f67420

File tree

2 files changed

+21
-138
lines changed

2 files changed

+21
-138
lines changed

src/stream/stream/mod.rs

Lines changed: 3 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ mod filter_map;
3030
mod find;
3131
mod find_map;
3232
mod fold;
33-
mod for_each;
3433
mod fuse;
3534
mod inspect;
36-
mod map;
3735
mod min_by;
3836
mod next;
3937
mod nth;
@@ -43,7 +41,6 @@ mod skip;
4341
mod skip_while;
4442
mod step_by;
4543
mod take;
46-
mod try_for_each;
4744
mod zip;
4845

4946
use all::AllFuture;
@@ -53,18 +50,15 @@ use filter_map::FilterMap;
5350
use find::FindFuture;
5451
use find_map::FindMapFuture;
5552
use fold::FoldFuture;
56-
use for_each::ForEachFuture;
5753
use min_by::MinByFuture;
5854
use next::NextFuture;
5955
use nth::NthFuture;
6056
use partial_cmp::PartialCmpFuture;
61-
use try_for_each::TryForEeachFuture;
6257

6358
pub use chain::Chain;
6459
pub use filter::Filter;
6560
pub use fuse::Fuse;
6661
pub use inspect::Inspect;
67-
pub use map::Map;
6862
pub use scan::Scan;
6963
pub use skip::Skip;
7064
pub use skip_while::SkipWhile;
@@ -346,37 +340,6 @@ extension_trait! {
346340
Enumerate::new(self)
347341
}
348342

349-
#[doc = r#"
350-
Takes a closure and creates a stream that calls that closure on every element of this stream.
351-
352-
# Examples
353-
354-
```
355-
# fn main() { async_std::task::block_on(async {
356-
#
357-
use async_std::prelude::*;
358-
use std::collections::VecDeque;
359-
360-
let s: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
361-
let mut s = s.map(|x| 2 * x);
362-
363-
assert_eq!(s.next().await, Some(2));
364-
assert_eq!(s.next().await, Some(4));
365-
assert_eq!(s.next().await, Some(6));
366-
assert_eq!(s.next().await, None);
367-
368-
#
369-
# }) }
370-
```
371-
"#]
372-
fn map<B, F>(self, f: F) -> Map<Self, F, Self::Item, B>
373-
where
374-
Self: Sized,
375-
F: FnMut(Self::Item) -> B,
376-
{
377-
Map::new(self, f)
378-
}
379-
380343
#[doc = r#"
381344
A combinator that does something with each element in the stream, passing the value
382345
on.
@@ -793,41 +756,6 @@ extension_trait! {
793756
FoldFuture::new(self, init, f)
794757
}
795758

796-
#[doc = r#"
797-
Call a closure on each element of the stream.
798-
799-
# Examples
800-
801-
```
802-
# fn main() { async_std::task::block_on(async {
803-
#
804-
use async_std::prelude::*;
805-
use std::collections::VecDeque;
806-
use std::sync::mpsc::channel;
807-
808-
let (tx, rx) = channel();
809-
810-
let s: VecDeque<usize> = vec![1, 2, 3].into_iter().collect();
811-
let sum = s.for_each(move |x| tx.clone().send(x).unwrap()).await;
812-
813-
let v: Vec<_> = rx.iter().collect();
814-
815-
assert_eq!(v, vec![1, 2, 3]);
816-
#
817-
# }) }
818-
```
819-
"#]
820-
fn for_each<F>(
821-
self,
822-
f: F,
823-
) -> impl Future<Output = ()> [ForEachFuture<Self, F, Self::Item>]
824-
where
825-
Self: Sized,
826-
F: FnMut(Self::Item),
827-
{
828-
ForEachFuture::new(self, f)
829-
}
830-
831759
#[doc = r#"
832760
Tests if any element of the stream matches a predicate.
833761
@@ -999,51 +927,6 @@ extension_trait! {
999927
Skip::new(self, n)
1000928
}
1001929

1002-
#[doc = r#"
1003-
Applies a falliable function to each element in a stream, stopping at first error and returning it.
1004-
1005-
# Examples
1006-
1007-
```
1008-
# fn main() { async_std::task::block_on(async {
1009-
#
1010-
use std::collections::VecDeque;
1011-
use std::sync::mpsc::channel;
1012-
use async_std::prelude::*;
1013-
1014-
let (tx, rx) = channel();
1015-
1016-
let s: VecDeque<usize> = vec![1, 2, 3].into_iter().collect();
1017-
let s = s.try_for_each(|v| {
1018-
if v % 2 == 1 {
1019-
tx.clone().send(v).unwrap();
1020-
Ok(())
1021-
} else {
1022-
Err("even")
1023-
}
1024-
});
1025-
1026-
let res = s.await;
1027-
drop(tx);
1028-
let values: Vec<_> = rx.iter().collect();
1029-
1030-
assert_eq!(values, vec![1]);
1031-
assert_eq!(res, Err("even"));
1032-
#
1033-
# }) }
1034-
```
1035-
"#]
1036-
fn try_for_each<F, E>(
1037-
self,
1038-
f: F,
1039-
) -> impl Future<Output = E> [TryForEeachFuture<Self, F, Self::Item, E>]
1040-
where
1041-
Self: Sized,
1042-
F: FnMut(Self::Item) -> Result<(), E>,
1043-
{
1044-
TryForEeachFuture::new(self, f)
1045-
}
1046-
1047930
#[doc = r#"
1048931
'Zips up' two streams into a single stream of pairs.
1049932
@@ -1221,11 +1104,11 @@ extension_trait! {
12211104
fn partial_cmp<S>(
12221105
self,
12231106
other: S
1224-
) -> impl Future<Output = Option<Ordering>> [PartialCmpFuture<Self, S>]
1107+
) -> impl Future<Output = Option<Ordering>> + '_ [PartialCmpFuture<Self, S>]
12251108
where
12261109
Self: Sized + Stream,
1227-
S: Stream,
1228-
<Self as Stream>::Item: PartialOrd<S::Item>,
1110+
S: Stream,
1111+
Self::Item: PartialOrd<S::Item>,
12291112
{
12301113
PartialCmpFuture::new(self, other)
12311114
}

src/stream/stream/partial_cmp.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::cmp::Ordering;
22
use std::pin::Pin;
33

44
use super::fuse::Fuse;
5-
use crate::future::Future;
65
use crate::prelude::*;
6+
use crate::future::Future;
77
use crate::stream::Stream;
88
use crate::task::{Context, Poll};
99

@@ -15,7 +15,7 @@ pub struct PartialCmpFuture<L: Stream, R: Stream> {
1515
l: Fuse<L>,
1616
r: Fuse<R>,
1717
l_cache: Option<L::Item>,
18-
r_cache: Option<R::Item>,
18+
r_cache: Option<R::Item>,
1919
}
2020

2121
impl<L: Stream, R: Stream> PartialCmpFuture<L, R> {
@@ -28,36 +28,36 @@ impl<L: Stream, R: Stream> PartialCmpFuture<L, R> {
2828
PartialCmpFuture {
2929
l: l.fuse(),
3030
r: r.fuse(),
31-
l_cache: None,
32-
r_cache: None,
31+
l_cache: None,
32+
r_cache: None,
3333
}
3434
}
3535
}
3636

37-
impl<L: Stream, R: Stream> Future for PartialCmpFuture<L, R>
38-
where
37+
impl<L: Stream, R: Stream> Future for PartialCmpFuture<L, R>
38+
where
3939
L: Stream + Sized,
4040
R: Stream + Sized,
41-
L::Item: PartialOrd<R::Item>,
41+
L::Item: PartialOrd<R::Item>
4242
{
4343
type Output = Option<Ordering>;
4444

45-
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
45+
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
4646
loop {
47-
// Short circuit logic
47+
// Short circuit logic
4848
// Stream that completes earliest can be considered Less, etc
4949
let l_complete = self.l.done && self.as_mut().l_cache.is_none();
5050
let r_complete = self.r.done && self.as_mut().r_cache.is_none();
5151

5252
if l_complete && r_complete {
53-
return Poll::Ready(Some(Ordering::Equal));
53+
return Poll::Ready(Some(Ordering::Equal))
5454
} else if l_complete {
55-
return Poll::Ready(Some(Ordering::Less));
55+
return Poll::Ready(Some(Ordering::Less))
5656
} else if r_complete {
57-
return Poll::Ready(Some(Ordering::Greater));
57+
return Poll::Ready(Some(Ordering::Greater))
5858
}
5959

60-
// Get next value if possible and necesary
60+
// Get next value if possible and necesary
6161
if !self.l.done && self.as_mut().l_cache.is_none() {
6262
let l_next = futures_core::ready!(self.as_mut().l().poll_next(cx));
6363
if let Some(item) = l_next {
@@ -75,17 +75,17 @@ where
7575
// Compare if both values are available.
7676
if self.as_mut().l_cache.is_some() && self.as_mut().r_cache.is_some() {
7777
let l_value = self.as_mut().l_cache().take().unwrap();
78-
let r_value = self.as_mut().r_cache().take().unwrap();
78+
let r_value = self.as_mut().r_cache().take().unwrap();
7979
let result = l_value.partial_cmp(&r_value);
8080

8181
if let Some(Ordering::Equal) = result {
82-
// Reset cache to prepare for next comparison
83-
*self.as_mut().l_cache() = None;
82+
// Reset cache to prepare for next comparison
83+
*self.as_mut().l_cache() = None;
8484
*self.as_mut().r_cache() = None;
8585
} else {
86-
// Return non equal value
86+
// Return non equal value
8787
return Poll::Ready(result);
88-
}
88+
}
8989
}
9090
}
9191
}

0 commit comments

Comments
 (0)