@@ -10,39 +10,37 @@ use std::prelude::v1::*;
10
10
/// This future is created by the `Stream::try_collect` method.
11
11
#[ derive( Debug ) ]
12
12
#[ must_use = "streams do nothing unless polled" ]
13
- pub struct TryCollect < S , C > where S : TryStream {
14
- stream : S ,
13
+ pub struct TryCollect < St , C > where St : TryStream {
14
+ stream : St ,
15
15
items : C ,
16
16
}
17
17
18
- pub fn new < S , C > ( s : S ) -> TryCollect < S , C >
19
- where S : TryStream , C : Default
20
- {
21
- TryCollect {
22
- stream : s,
23
- items : Default :: default ( ) ,
18
+ impl < St : TryStream , C : Default > TryCollect < St , C > {
19
+ unsafe_pinned ! ( stream: St ) ;
20
+ unsafe_unpinned ! ( items: C ) ;
21
+
22
+ pub ( super ) fn new ( s : St ) -> TryCollect < St , C > {
23
+ TryCollect {
24
+ stream : s,
25
+ items : Default :: default ( ) ,
26
+ }
24
27
}
25
- }
26
28
27
- impl < S : TryStream , C : Default > TryCollect < S , C > {
28
29
fn finish ( mut self : PinMut < Self > ) -> C {
29
30
mem:: replace ( self . items ( ) , Default :: default ( ) )
30
31
}
31
-
32
- unsafe_pinned ! ( stream: S ) ;
33
- unsafe_unpinned ! ( items: C ) ;
34
32
}
35
33
36
- impl < S : Unpin + TryStream , C > Unpin for TryCollect < S , C > { }
34
+ impl < St : Unpin + TryStream , C > Unpin for TryCollect < St , C > { }
37
35
38
- impl < S , C > Future for TryCollect < S , C >
39
- where S : TryStream , C : Default + Extend < S :: Ok >
36
+ impl < St , C > Future for TryCollect < St , C >
37
+ where St : TryStream , C : Default + Extend < St :: Ok >
40
38
{
41
- type Output = Result < C , S :: Error > ;
39
+ type Output = Result < C , St :: Error > ;
42
40
43
41
fn poll (
44
42
mut self : PinMut < Self > ,
45
- cx : & mut task:: Context
43
+ cx : & mut task:: Context ,
46
44
) -> Poll < Self :: Output > {
47
45
loop {
48
46
match ready ! ( self . stream( ) . try_poll_next( cx) ) {
0 commit comments