File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 1- use std:: marker:: PhantomData ;
21use std:: pin:: Pin ;
32use std:: mem;
43
@@ -12,19 +11,18 @@ pin_project_lite::pin_project! {
1211 /// A stream that yields elements by calling an async closure with the previous value as an
1312 /// argument
1413 ///
15- /// This stream is constructed by [`successor `] function
14+ /// This stream is constructed by [`successors `] function
1615 ///
17- /// [`successor `]: fn.successor .html
16+ /// [`succcessors `]: fn.succssors .html
1817 #[ derive( Debug ) ]
1918 pub struct Successors <F , Fut , T >
2019 where
2120 Fut : Future <Output = Option <T >>,
2221 {
23- successor : F ,
22+ succ : F ,
2423 #[ pin]
2524 future: Option <Fut >,
2625 slot: Option <T >,
27- _marker: PhantomData <Fut >,
2826 }
2927}
3028
7270 T : Copy ,
7371{
7472 Successors {
75- successor : succ,
73+ succ : succ,
7674 future : None ,
7775 slot : first,
78- _marker : PhantomData ,
7976 }
8077}
8178
@@ -95,14 +92,15 @@ where
9592 }
9693
9794 if this. future . is_none ( ) {
98- let x = this. slot . unwrap ( ) ;
99- let fut = ( this. successor ) ( x) ;
95+ let fut = ( this. succ ) ( this. slot . unwrap ( ) ) ;
10096 this. future . set ( Some ( fut) ) ;
10197 }
10298
10399 let mut next = ready ! ( this. future. as_mut( ) . as_pin_mut( ) . unwrap( ) . poll( cx) ) ;
104100
105101 this. future . set ( None ) ;
102+
103+ // 'swapping' here means 'slot' will hold the next value and next will be th one from the previous iteration
106104 mem:: swap ( this. slot , & mut next) ;
107105 Poll :: Ready ( next)
108106 }
You can’t perform that action at this time.
0 commit comments