1- use std:: pin:: Pin ;
21use std:: marker:: PhantomData ;
2+ use std:: pin:: Pin ;
33
44use crate :: future:: Future ;
55use crate :: stream:: Stream ;
@@ -12,13 +12,14 @@ use crate::task::{Context, Poll};
1212///
1313/// [`successor`]: fn.successor.html
1414#[ derive( Debug ) ]
15- pub struct Successor < F , Fut , T >
16- where Fut : Future < Output =T >
15+ pub struct Successor < F , Fut , T >
16+ where
17+ Fut : Future < Output = T > ,
1718{
1819 successor : F ,
1920 future : Option < Fut > ,
2021 next : T ,
21- _marker : PhantomData < Fut >
22+ _marker : PhantomData < Fut > ,
2223}
2324
2425/// Creates a new stream where to produce each new element a clousre is called with the previous
@@ -51,29 +52,27 @@ where
5152 F : FnMut ( T ) -> Fut ,
5253 Fut : Future < Output = T > ,
5354 T : Copy ,
54- {
55- Successor {
56- successor : func,
57- future : None ,
58- next : start,
59- _marker : PhantomData ,
60- }
55+ {
56+ Successor {
57+ successor : func,
58+ future : None ,
59+ next : start,
60+ _marker : PhantomData ,
6161 }
62+ }
6263
63- impl < F , Fut , T > Successor < F , Fut , T >
64+ impl < F , Fut , T > Successor < F , Fut , T >
6465where
6566 F : FnMut ( T ) -> Fut ,
6667 Fut : Future < Output = T > ,
6768 T : Copy ,
68-
6969{
7070 pin_utils:: unsafe_unpinned!( successor: F ) ;
7171 pin_utils:: unsafe_unpinned!( next: T ) ;
7272 pin_utils:: unsafe_pinned!( future: Option <Fut >) ;
73-
7473}
7574
76- impl < F , Fut , T > Stream for Successor < F , Fut , T >
75+ impl < F , Fut , T > Stream for Successor < F , Fut , T >
7776where
7877 Fut : Future < Output = T > ,
7978 F : FnMut ( T ) -> Fut ,
8887 let fut = ( self . as_mut ( ) . successor ( ) ) ( x) ;
8988 self . as_mut ( ) . future ( ) . set ( Some ( fut) ) ;
9089 }
91- _ => { } ,
90+ _ => { }
9291 }
9392
9493 let next = futures_core:: ready!( self . as_mut( ) . future( ) . as_pin_mut( ) . unwrap( ) . poll( cx) ) ;
9796 Poll :: Ready ( Some ( next) )
9897 }
9998}
100-
0 commit comments