Merge pull request #548 from yjhmelody/fix-stream-code-style

fix stream code style
pull/567/head
Yoshua Wuyts 5 years ago committed by GitHub
commit d1189f9974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,6 +14,17 @@ pub struct AllFuture<'a, S, F, T> {
pub(crate) _marker: PhantomData<T>,
}
impl<'a, S, F, T> AllFuture<'a, S, F, T> {
pub(crate) fn new(stream: &'a mut S, f: F) -> Self {
Self {
stream,
f,
result: true, // the default if the empty stream
_marker: PhantomData,
}
}
}
impl<S: Unpin, F, T> Unpin for AllFuture<'_, S, F, T> {}
impl<S, F> Future for AllFuture<'_, S, F, S::Item>

@ -14,6 +14,17 @@ pub struct AnyFuture<'a, S, F, T> {
pub(crate) _marker: PhantomData<T>,
}
impl<'a, S, F, T> AnyFuture<'a, S, F, T> {
pub(crate) fn new(stream: &'a mut S, f: F) -> Self {
Self {
stream,
f,
result: false, // the default if the empty stream
_marker: PhantomData,
}
}
}
impl<S: Unpin, F, T> Unpin for AnyFuture<'_, S, F, T> {}
impl<S, F> Future for AnyFuture<'_, S, F, S::Item>

@ -25,7 +25,7 @@ pin_project! {
impl<S: Stream, U: Stream> Chain<S, U> {
pub(super) fn new(first: S, second: U) -> Self {
Chain {
Self {
first: first.fuse(),
second: second.fuse(),
}

@ -26,7 +26,7 @@ pin_project! {
impl<L: Stream, R: Stream> CmpFuture<L, R> {
pub(super) fn new(l: L, r: R) -> Self {
CmpFuture {
Self {
l: l.fuse(),
r: r.fuse(),
l_cache: None,

@ -14,7 +14,7 @@ pin_project! {
impl<S> Copied<S> {
pub(super) fn new(stream: S) -> Self {
Copied { stream }
Self { stream }
}
}

@ -20,7 +20,7 @@ pin_project! {
impl<S> CountFuture<S> {
pub(crate) fn new(stream: S) -> Self {
CountFuture { stream, count: 0 }
Self { stream, count: 0 }
}
}

@ -15,8 +15,8 @@ impl<S> Cycle<S>
where
S: Stream + Clone,
{
pub fn new(source: S) -> Cycle<S> {
Cycle {
pub(crate) fn new(source: S) -> Self {
Self {
orig: source.clone(),
source: ManuallyDrop::new(source),
}

@ -16,7 +16,7 @@ pin_project! {
impl<S> Enumerate<S> {
pub(super) fn new(stream: S) -> Self {
Enumerate { stream, i: 0 }
Self { stream, i: 0 }
}
}

@ -26,7 +26,7 @@ where
L::Item: PartialEq<R::Item>,
{
pub(super) fn new(l: L, r: R) -> Self {
EqFuture {
Self {
l: l.fuse(),
r: r.fuse(),
}

@ -23,7 +23,7 @@ pin_project! {
impl<S, P> Filter<S, P> {
pub(super) fn new(stream: S, predicate: P) -> Self {
Filter {
Self {
stream,
predicate,
}

@ -16,7 +16,7 @@ pin_project! {
impl<S, F> FilterMap<S, F> {
pub(crate) fn new(stream: S, f: F) -> Self {
FilterMap { stream, f }
Self { stream, f }
}
}

@ -13,7 +13,7 @@ pub struct FindFuture<'a, S, P> {
impl<'a, S, P> FindFuture<'a, S, P> {
pub(super) fn new(stream: &'a mut S, p: P) -> Self {
FindFuture { stream, p }
Self { stream, p }
}
}

@ -13,7 +13,7 @@ pub struct FindMapFuture<'a, S, F> {
impl<'a, S, F> FindMapFuture<'a, S, F> {
pub(super) fn new(stream: &'a mut S, f: F) -> Self {
FindMapFuture { stream, f }
Self { stream, f }
}
}

@ -30,8 +30,8 @@ where
U: IntoStream,
F: FnMut(S::Item) -> U,
{
pub(super) fn new(stream: S, f: F) -> FlatMap<S, U, F> {
FlatMap {
pub(super) fn new(stream: S, f: F) -> Self {
Self {
stream: stream.map(f),
inner_stream: None,
}

@ -32,8 +32,8 @@ where
S: Stream,
S::Item: IntoStream,
{
pub(super) fn new(stream: S) -> Flatten<S> {
Flatten {
pub(super) fn new(stream: S) -> Self {
Self {
stream,
inner_stream: None,
}

@ -18,7 +18,7 @@ pin_project! {
impl<S, F, B> FoldFuture<S, F, B> {
pub(super) fn new(stream: S, init: B, f: F) -> Self {
FoldFuture {
Self {
stream,
f,
acc: Some(init),

@ -18,7 +18,7 @@ pin_project! {
impl<S, F> ForEachFuture<S, F> {
pub(super) fn new(stream: S, f: F) -> Self {
ForEachFuture {
Self {
stream,
f,
}

@ -21,6 +21,15 @@ pin_project! {
}
}
impl<S> Fuse<S> {
pub(super) fn new(stream: S) -> Self {
Self {
stream,
done: false,
}
}
}
impl<S: Stream> Stream for Fuse<S> {
type Item = S::Item;

@ -25,7 +25,7 @@ where
L::Item: PartialOrd<R::Item>,
{
pub(super) fn new(l: L, r: R) -> Self {
GeFuture {
Self {
partial_cmp: l.partial_cmp(r),
}
}

@ -25,7 +25,7 @@ where
L::Item: PartialOrd<R::Item>,
{
pub(super) fn new(l: L, r: R) -> Self {
GtFuture {
Self {
partial_cmp: l.partial_cmp(r),
}
}

@ -23,7 +23,7 @@ pin_project! {
impl<S, F> Inspect<S, F> {
pub(super) fn new(stream: S, f: F) -> Self {
Inspect {
Self {
stream,
f,
}

@ -18,7 +18,7 @@ pin_project! {
impl<S, T> LastFuture<S, T> {
pub(crate) fn new(stream: S) -> Self {
LastFuture { stream, last: None }
Self { stream, last: None }
}
}

@ -25,7 +25,7 @@ where
L::Item: PartialOrd<R::Item>,
{
pub(super) fn new(l: L, r: R) -> Self {
LeFuture {
Self {
partial_cmp: l.partial_cmp(r),
}
}

@ -25,7 +25,7 @@ where
L::Item: PartialOrd<R::Item>,
{
pub(super) fn new(l: L, r: R) -> Self {
LtFuture {
Self {
partial_cmp: l.partial_cmp(r),
}
}

@ -17,7 +17,7 @@ pin_project! {
impl<S, F> Map<S, F> {
pub(crate) fn new(stream: S, f: F) -> Self {
Map {
Self {
stream,
f,
}

@ -20,7 +20,7 @@ pin_project! {
impl<S, F, T> MaxByFuture<S, F, T> {
pub(super) fn new(stream: S, compare: F) -> Self {
MaxByFuture {
Self {
stream,
compare,
max: None,

@ -20,7 +20,7 @@ pin_project! {
impl<S, F, T> MinByFuture<S, F, T> {
pub(super) fn new(stream: S, compare: F) -> Self {
MinByFuture {
Self {
stream,
compare,
min: None,

@ -20,7 +20,7 @@ pin_project! {
impl<S, T, K> MinByKeyFuture<S, T, K> {
pub(super) fn new(stream: S, key_by: K) -> Self {
MinByKeyFuture {
Self {
stream,
min: None,
key_by,

@ -111,7 +111,6 @@ pub use take_while::TakeWhile;
pub use zip::Zip;
use std::cmp::Ordering;
use std::marker::PhantomData;
cfg_unstable! {
use std::future::Future;
@ -288,10 +287,7 @@ extension_trait! {
where
Self: Sized,
{
Take {
stream: self,
remaining: n,
}
Take::new(self, n)
}
#[doc = r#"
@ -714,10 +710,7 @@ extension_trait! {
where
Self: Sized,
{
Fuse {
stream: self,
done: false,
}
Fuse::new(self)
}
#[doc = r#"
@ -1193,12 +1186,7 @@ extension_trait! {
Self: Unpin + Sized,
F: FnMut(Self::Item) -> bool,
{
AllFuture {
stream: self,
result: true, // the default if the empty stream
_marker: PhantomData,
f,
}
AllFuture::new(self, f)
}
#[doc = r#"
@ -1438,12 +1426,7 @@ extension_trait! {
Self: Unpin + Sized,
F: FnMut(Self::Item) -> bool,
{
AnyFuture {
stream: self,
result: false, // the default if the empty stream
_marker: PhantomData,
f,
}
AnyFuture::new(self, f)
}
#[doc = r#"
@ -1468,7 +1451,7 @@ extension_trait! {
assert_eq!(sum, 6);
// if we try to use stream again, it won't work. The following line
// gives "error: use of moved value: `stream`
// gives error: use of moved value: `stream`
// assert_eq!(stream.next(), None);
// let's try that again

@ -15,7 +15,7 @@ impl<S: Unpin> Unpin for NthFuture<'_, S> {}
impl<'a, S> NthFuture<'a, S> {
pub(crate) fn new(stream: &'a mut S, n: usize) -> Self {
NthFuture { stream, n }
Self { stream, n }
}
}

@ -26,7 +26,7 @@ pin_project! {
impl<L: Stream, R: Stream> PartialCmpFuture<L, R> {
pub(super) fn new(l: L, r: R) -> Self {
PartialCmpFuture {
Self {
l: l.fuse(),
r: r.fuse(),
l_cache: None,

@ -16,7 +16,7 @@ impl<'a, S, P> Unpin for PositionFuture<'a, S, P> {}
impl<'a, S, P> PositionFuture<'a, S, P> {
pub(super) fn new(stream: &'a mut S, predicate: P) -> Self {
PositionFuture {
Self {
stream,
predicate,
index: 0,

@ -23,7 +23,7 @@ pin_project! {
impl<S> Skip<S> {
pub(crate) fn new(stream: S, n: usize) -> Self {
Skip { stream, n }
Self { stream, n }
}
}

@ -23,7 +23,7 @@ pin_project! {
impl<S, P> SkipWhile<S, P> {
pub(crate) fn new(stream: S, predicate: P) -> Self {
SkipWhile {
Self {
stream,
predicate: Some(predicate),
}

@ -24,7 +24,7 @@ pin_project! {
impl<S> StepBy<S> {
pub(crate) fn new(stream: S, step: usize) -> Self {
StepBy {
Self {
stream,
step: step.checked_sub(1).unwrap(),
i: 0,

@ -21,6 +21,15 @@ pin_project! {
}
}
impl<S> Take<S> {
pub(super) fn new(stream: S, remaining: usize) -> Self {
Self {
stream,
remaining,
}
}
}
impl<S: Stream> Stream for Take<S> {
type Item = S::Item;

@ -23,7 +23,7 @@ pin_project! {
impl<S, P> TakeWhile<S, P> {
pub(super) fn new(stream: S, predicate: P) -> Self {
TakeWhile {
Self {
stream,
predicate,
}

@ -31,7 +31,7 @@ pin_project! {
impl<S: Stream> Throttle<S> {
pub(super) fn new(stream: S, duration: Duration) -> Self {
Throttle {
Self {
stream,
duration,
blocked: false,

@ -22,10 +22,10 @@ pin_project! {
}
impl<S: Stream> Timeout<S> {
pub(crate) fn new(stream: S, dur: Duration) -> Timeout<S> {
pub(crate) fn new(stream: S, dur: Duration) -> Self {
let delay = Delay::new(dur);
Timeout { stream, delay }
Self { stream, delay }
}
}

@ -16,7 +16,7 @@ impl<'a, S, F, T> Unpin for TryFoldFuture<'a, S, F, T> {}
impl<'a, S, F, T> TryFoldFuture<'a, S, F, T> {
pub(super) fn new(stream: &'a mut S, init: T, f: F) -> Self {
TryFoldFuture {
Self {
stream,
f,
acc: Some(init),

@ -15,7 +15,7 @@ impl<'a, S, F> Unpin for TryForEachFuture<'a, S, F> {}
impl<'a, S, F> TryForEachFuture<'a, S, F> {
pub(crate) fn new(stream: &'a mut S, f: F) -> Self {
TryForEachFuture { stream, f }
Self { stream, f }
}
}

@ -34,7 +34,7 @@ impl<A: Stream + fmt::Debug, B: fmt::Debug> fmt::Debug for Zip<A, B> {
impl<A: Stream, B> Zip<A, B> {
pub(crate) fn new(first: A, second: B) -> Self {
Zip {
Self {
item_slot: None,
first,
second,

Loading…
Cancel
Save