Skip to content

Commit 223fcc3

Browse files
committed
fix code style for stream
1 parent a69b3a8 commit 223fcc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+86
-63
lines changed

src/stream/stream/all.rs

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ pub struct AllFuture<'a, S, F, T> {
1414
pub(crate) _marker: PhantomData<T>,
1515
}
1616

17+
impl<'a, S, F, T> AllFuture<'a, S, F, T> {
18+
pub(crate) fn new(stream: &'a mut S, f: F) -> Self {
19+
Self {
20+
stream,
21+
f,
22+
result: true, // the default if the empty stream
23+
_marker: PhantomData,
24+
}
25+
}
26+
}
27+
1728
impl<S: Unpin, F, T> Unpin for AllFuture<'_, S, F, T> {}
1829

1930
impl<S, F> Future for AllFuture<'_, S, F, S::Item>

src/stream/stream/any.rs

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ pub struct AnyFuture<'a, S, F, T> {
1414
pub(crate) _marker: PhantomData<T>,
1515
}
1616

17+
impl<'a, S, F, T> AnyFuture<'a, S, F, T> {
18+
pub(crate) fn new(stream: &'a mut S, f: F) -> Self {
19+
Self {
20+
stream,
21+
f,
22+
result: false, // the default if the empty stream
23+
_marker: PhantomData,
24+
}
25+
}
26+
}
27+
1728
impl<S: Unpin, F, T> Unpin for AnyFuture<'_, S, F, T> {}
1829

1930
impl<S, F> Future for AnyFuture<'_, S, F, S::Item>

src/stream/stream/chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pin_project! {
2525

2626
impl<S: Stream, U: Stream> Chain<S, U> {
2727
pub(super) fn new(first: S, second: U) -> Self {
28-
Chain {
28+
Self {
2929
first: first.fuse(),
3030
second: second.fuse(),
3131
}

src/stream/stream/cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pin_project! {
2626

2727
impl<L: Stream, R: Stream> CmpFuture<L, R> {
2828
pub(super) fn new(l: L, r: R) -> Self {
29-
CmpFuture {
29+
Self {
3030
l: l.fuse(),
3131
r: r.fuse(),
3232
l_cache: None,

src/stream/stream/copied.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pin_project! {
1414

1515
impl<S> Copied<S> {
1616
pub(super) fn new(stream: S) -> Self {
17-
Copied { stream }
17+
Self { stream }
1818
}
1919
}
2020

src/stream/stream/count.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pin_project! {
2020

2121
impl<S> CountFuture<S> {
2222
pub(crate) fn new(stream: S) -> Self {
23-
CountFuture { stream, count: 0 }
23+
Self { stream, count: 0 }
2424
}
2525
}
2626

src/stream/stream/cycle.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ impl<S> Cycle<S>
1515
where
1616
S: Stream + Clone,
1717
{
18-
pub fn new(source: S) -> Cycle<S> {
19-
Cycle {
18+
pub(crate) fn new(source: S) -> Self {
19+
Self {
2020
orig: source.clone(),
2121
source: ManuallyDrop::new(source),
2222
}

src/stream/stream/enumerate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pin_project! {
1616

1717
impl<S> Enumerate<S> {
1818
pub(super) fn new(stream: S) -> Self {
19-
Enumerate { stream, i: 0 }
19+
Self { stream, i: 0 }
2020
}
2121
}
2222

src/stream/stream/eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
L::Item: PartialEq<R::Item>,
2727
{
2828
pub(super) fn new(l: L, r: R) -> Self {
29-
EqFuture {
29+
Self {
3030
l: l.fuse(),
3131
r: r.fuse(),
3232
}

src/stream/stream/filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pin_project! {
2323

2424
impl<S, P> Filter<S, P> {
2525
pub(super) fn new(stream: S, predicate: P) -> Self {
26-
Filter {
26+
Self {
2727
stream,
2828
predicate,
2929
}

src/stream/stream/filter_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pin_project! {
1616

1717
impl<S, F> FilterMap<S, F> {
1818
pub(crate) fn new(stream: S, f: F) -> Self {
19-
FilterMap { stream, f }
19+
Self { stream, f }
2020
}
2121
}
2222

src/stream/stream/find.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct FindFuture<'a, S, P> {
1313

1414
impl<'a, S, P> FindFuture<'a, S, P> {
1515
pub(super) fn new(stream: &'a mut S, p: P) -> Self {
16-
FindFuture { stream, p }
16+
Self { stream, p }
1717
}
1818
}
1919

src/stream/stream/find_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct FindMapFuture<'a, S, F> {
1313

1414
impl<'a, S, F> FindMapFuture<'a, S, F> {
1515
pub(super) fn new(stream: &'a mut S, f: F) -> Self {
16-
FindMapFuture { stream, f }
16+
Self { stream, f }
1717
}
1818
}
1919

src/stream/stream/flat_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ where
3030
U: IntoStream,
3131
F: FnMut(S::Item) -> U,
3232
{
33-
pub(super) fn new(stream: S, f: F) -> FlatMap<S, U, F> {
34-
FlatMap {
33+
pub(super) fn new(stream: S, f: F) -> Self {
34+
Self {
3535
stream: stream.map(f),
3636
inner_stream: None,
3737
}

src/stream/stream/flatten.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ where
3232
S: Stream,
3333
S::Item: IntoStream,
3434
{
35-
pub(super) fn new(stream: S) -> Flatten<S> {
36-
Flatten {
35+
pub(super) fn new(stream: S) -> Self {
36+
Self {
3737
stream,
3838
inner_stream: None,
3939
}

src/stream/stream/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pin_project! {
1818

1919
impl<S, F, B> FoldFuture<S, F, B> {
2020
pub(super) fn new(stream: S, init: B, f: F) -> Self {
21-
FoldFuture {
21+
Self {
2222
stream,
2323
f,
2424
acc: Some(init),

src/stream/stream/for_each.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pin_project! {
1818

1919
impl<S, F> ForEachFuture<S, F> {
2020
pub(super) fn new(stream: S, f: F) -> Self {
21-
ForEachFuture {
21+
Self {
2222
stream,
2323
f,
2424
}

src/stream/stream/fuse.rs

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ pin_project! {
2121
}
2222
}
2323

24+
impl<S> Fuse<S> {
25+
pub(super) fn new(stream: S) -> Self {
26+
Self {
27+
stream,
28+
done: false,
29+
}
30+
}
31+
}
32+
2433
impl<S: Stream> Stream for Fuse<S> {
2534
type Item = S::Item;
2635

src/stream/stream/ge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ where
2525
L::Item: PartialOrd<R::Item>,
2626
{
2727
pub(super) fn new(l: L, r: R) -> Self {
28-
GeFuture {
28+
Self {
2929
partial_cmp: l.partial_cmp(r),
3030
}
3131
}

src/stream/stream/gt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ where
2525
L::Item: PartialOrd<R::Item>,
2626
{
2727
pub(super) fn new(l: L, r: R) -> Self {
28-
GtFuture {
28+
Self {
2929
partial_cmp: l.partial_cmp(r),
3030
}
3131
}

src/stream/stream/inspect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pin_project! {
2323

2424
impl<S, F> Inspect<S, F> {
2525
pub(super) fn new(stream: S, f: F) -> Self {
26-
Inspect {
26+
Self {
2727
stream,
2828
f,
2929
}

src/stream/stream/last.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pin_project! {
1818

1919
impl<S, T> LastFuture<S, T> {
2020
pub(crate) fn new(stream: S) -> Self {
21-
LastFuture { stream, last: None }
21+
Self { stream, last: None }
2222
}
2323
}
2424

src/stream/stream/le.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ where
2525
L::Item: PartialOrd<R::Item>,
2626
{
2727
pub(super) fn new(l: L, r: R) -> Self {
28-
LeFuture {
28+
Self {
2929
partial_cmp: l.partial_cmp(r),
3030
}
3131
}

src/stream/stream/lt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ where
2525
L::Item: PartialOrd<R::Item>,
2626
{
2727
pub(super) fn new(l: L, r: R) -> Self {
28-
LtFuture {
28+
Self {
2929
partial_cmp: l.partial_cmp(r),
3030
}
3131
}

src/stream/stream/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pin_project! {
1717

1818
impl<S, F> Map<S, F> {
1919
pub(crate) fn new(stream: S, f: F) -> Self {
20-
Map {
20+
Self {
2121
stream,
2222
f,
2323
}

src/stream/stream/max_by.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pin_project! {
2020

2121
impl<S, F, T> MaxByFuture<S, F, T> {
2222
pub(super) fn new(stream: S, compare: F) -> Self {
23-
MaxByFuture {
23+
Self {
2424
stream,
2525
compare,
2626
max: None,

src/stream/stream/min_by.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pin_project! {
2020

2121
impl<S, F, T> MinByFuture<S, F, T> {
2222
pub(super) fn new(stream: S, compare: F) -> Self {
23-
MinByFuture {
23+
Self {
2424
stream,
2525
compare,
2626
min: None,

src/stream/stream/min_by_key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pin_project! {
2020

2121
impl<S, T, K> MinByKeyFuture<S, T, K> {
2222
pub(super) fn new(stream: S, key_by: K) -> Self {
23-
MinByKeyFuture {
23+
Self {
2424
stream,
2525
min: None,
2626
key_by,

src/stream/stream/mod.rs

+5-22
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ pub use take_while::TakeWhile;
111111
pub use zip::Zip;
112112

113113
use std::cmp::Ordering;
114-
use std::marker::PhantomData;
115114

116115
cfg_unstable! {
117116
use std::future::Future;
@@ -288,10 +287,7 @@ extension_trait! {
288287
where
289288
Self: Sized,
290289
{
291-
Take {
292-
stream: self,
293-
remaining: n,
294-
}
290+
Take::new(self, n)
295291
}
296292

297293
#[doc = r#"
@@ -714,10 +710,7 @@ extension_trait! {
714710
where
715711
Self: Sized,
716712
{
717-
Fuse {
718-
stream: self,
719-
done: false,
720-
}
713+
Fuse::new(self)
721714
}
722715

723716
#[doc = r#"
@@ -1193,12 +1186,7 @@ extension_trait! {
11931186
Self: Unpin + Sized,
11941187
F: FnMut(Self::Item) -> bool,
11951188
{
1196-
AllFuture {
1197-
stream: self,
1198-
result: true, // the default if the empty stream
1199-
_marker: PhantomData,
1200-
f,
1201-
}
1189+
AllFuture::new(self, f)
12021190
}
12031191

12041192
#[doc = r#"
@@ -1438,12 +1426,7 @@ extension_trait! {
14381426
Self: Unpin + Sized,
14391427
F: FnMut(Self::Item) -> bool,
14401428
{
1441-
AnyFuture {
1442-
stream: self,
1443-
result: false, // the default if the empty stream
1444-
_marker: PhantomData,
1445-
f,
1446-
}
1429+
AnyFuture::new(self, f)
14471430
}
14481431

14491432
#[doc = r#"
@@ -1468,7 +1451,7 @@ extension_trait! {
14681451
assert_eq!(sum, 6);
14691452
14701453
// if we try to use stream again, it won't work. The following line
1471-
// gives "error: use of moved value: `stream`
1454+
// gives error: use of moved value: `stream`
14721455
// assert_eq!(stream.next(), None);
14731456
14741457
// let's try that again

src/stream/stream/nth.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<S: Unpin> Unpin for NthFuture<'_, S> {}
1515

1616
impl<'a, S> NthFuture<'a, S> {
1717
pub(crate) fn new(stream: &'a mut S, n: usize) -> Self {
18-
NthFuture { stream, n }
18+
Self { stream, n }
1919
}
2020
}
2121

src/stream/stream/partial_cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pin_project! {
2626

2727
impl<L: Stream, R: Stream> PartialCmpFuture<L, R> {
2828
pub(super) fn new(l: L, r: R) -> Self {
29-
PartialCmpFuture {
29+
Self {
3030
l: l.fuse(),
3131
r: r.fuse(),
3232
l_cache: None,

src/stream/stream/position.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl<'a, S, P> Unpin for PositionFuture<'a, S, P> {}
1616

1717
impl<'a, S, P> PositionFuture<'a, S, P> {
1818
pub(super) fn new(stream: &'a mut S, predicate: P) -> Self {
19-
PositionFuture {
19+
Self {
2020
stream,
2121
predicate,
2222
index: 0,

src/stream/stream/skip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pin_project! {
2323

2424
impl<S> Skip<S> {
2525
pub(crate) fn new(stream: S, n: usize) -> Self {
26-
Skip { stream, n }
26+
Self { stream, n }
2727
}
2828
}
2929

src/stream/stream/skip_while.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pin_project! {
2323

2424
impl<S, P> SkipWhile<S, P> {
2525
pub(crate) fn new(stream: S, predicate: P) -> Self {
26-
SkipWhile {
26+
Self {
2727
stream,
2828
predicate: Some(predicate),
2929
}

0 commit comments

Comments
 (0)