@@ -60,36 +60,42 @@ pub(crate) trait Context {
6060}
6161
6262#[ cfg( all( not( target_os = "unknown" ) , feature = "default" ) ) ]
63- pub ( crate ) type Timer = smol:: Timer ;
63+ mod timer {
64+ pub type Timer = smol:: Timer ;
65+ }
6466
65- #[ cfg( all( target_arch = "wasm32" , feature = "default" ) ) ]
66- #[ derive( Debug ) ]
67- pub ( crate ) struct Timer ( futures_timer:: Delay ) ;
67+ #[ cfg( any(
68+ all( target_arch = "wasm32" , feature = "default" ) ,
69+ all( feature = "unstable" , not( feature = "default" ) )
70+ ) ) ]
71+ mod timer {
72+ use std:: pin:: Pin ;
73+ use std:: task:: Poll ;
6874
69- #[ cfg( all( target_arch = "wasm32" , feature = "default" ) ) ]
70- impl Timer {
71- pub ( crate ) fn after ( dur : std:: time:: Duration ) -> Self {
72- Timer ( futures_timer:: Delay :: new ( dur) )
73- }
74- }
75+ #[ derive( Debug ) ]
76+ pub ( crate ) struct Timer ( futures_timer:: Delay ) ;
7577
76- #[ cfg( target_arch = "wasm32" ) ]
77- use std:: pin:: Pin ;
78- #[ cfg( target_arch = "wasm32" ) ]
79- use std:: task:: Poll ;
78+ impl Timer {
79+ pub ( crate ) fn after ( dur : std:: time:: Duration ) -> Self {
80+ Timer ( futures_timer:: Delay :: new ( dur) )
81+ }
82+ }
8083
81- #[ cfg( target_arch = "wasm32" ) ]
82- impl std:: future:: Future for Timer {
83- type Output = ( ) ;
84+ impl std:: future:: Future for Timer {
85+ type Output = ( ) ;
8486
85- fn poll ( mut self : Pin < & mut Self > , cx : & mut std:: task:: Context < ' _ > ) -> Poll < Self :: Output > {
86- match Pin :: new ( & mut self . 0 ) . poll ( cx) {
87- Poll :: Pending => Poll :: Pending ,
88- Poll :: Ready ( _) => Poll :: Ready ( ( ) ) ,
87+ fn poll ( mut self : Pin < & mut Self > , cx : & mut std:: task:: Context < ' _ > ) -> Poll < Self :: Output > {
88+ match Pin :: new ( & mut self . 0 ) . poll ( cx) {
89+ Poll :: Pending => Poll :: Pending ,
90+ Poll :: Ready ( _) => Poll :: Ready ( ( ) ) ,
91+ }
8992 }
9093 }
9194}
9295
96+ #[ cfg( any( feature = "unstable" , feature = "default" ) ) ]
97+ pub ( crate ) use timer:: * ;
98+
9399/// Defers evaluation of a block of code until the end of the scope.
94100#[ cfg( feature = "default" ) ]
95101#[ doc( hidden) ]
0 commit comments