11use crate :: Stream ;
22
33use core:: future:: Future ;
4- use core:: marker:: PhantomPinned ;
4+ use core:: marker:: { PhantomData , PhantomPinned } ;
55use core:: mem;
66use core:: pin:: Pin ;
77use core:: task:: { ready, Context , Poll } ;
@@ -12,14 +12,12 @@ pin_project! {
1212 /// Future returned by the [`collect`](super::StreamExt::collect) method.
1313 #[ must_use = "futures do nothing unless you `.await` or poll them" ]
1414 #[ derive( Debug ) ]
15- pub struct Collect <T , U >
16- where
17- T : Stream ,
18- U : FromStream <T :: Item >,
15+ pub struct Collect <T , U , C >
1916 {
2017 #[ pin]
2118 stream: T ,
22- collection: U :: InternalCollection ,
19+ collection: C ,
20+ _output: PhantomData <U >,
2321 // Make this future `!Unpin` for compatibility with async trait methods.
2422 #[ pin]
2523 _pin: PhantomPinned ,
@@ -38,24 +36,25 @@ pin_project! {
3836/// enhancements to the Rust language.
3937pub trait FromStream < T > : sealed:: FromStreamPriv < T > { }
4038
41- impl < T , U > Collect < T , U >
39+ impl < T , U > Collect < T , U , U :: InternalCollection >
4240where
4341 T : Stream ,
4442 U : FromStream < T :: Item > ,
4543{
46- pub ( super ) fn new ( stream : T ) -> Collect < T , U > {
44+ pub ( super ) fn new ( stream : T ) -> Collect < T , U , U :: InternalCollection > {
4745 let ( lower, upper) = stream. size_hint ( ) ;
4846 let collection = U :: initialize ( sealed:: Internal , lower, upper) ;
4947
5048 Collect {
5149 stream,
5250 collection,
51+ _output : PhantomData ,
5352 _pin : PhantomPinned ,
5453 }
5554 }
5655}
5756
58- impl < T , U > Future for Collect < T , U >
57+ impl < T , U > Future for Collect < T , U , U :: InternalCollection >
5958where
6059 T : Stream ,
6160 U : FromStream < T :: Item > ,
0 commit comments