@@ -60,36 +60,38 @@ 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( all( target_arch = "wasm32" , feature = "default" ) , feature = "unstable" ) ) ]
68+ mod timer {
69+ use std:: pin:: Pin ;
70+ use std:: task:: Poll ;
6871
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- }
72+ #[ derive( Debug ) ]
73+ pub ( crate ) struct Timer ( futures_timer:: Delay ) ;
7574
76- #[ cfg( target_arch = "wasm32" ) ]
77- use std:: pin:: Pin ;
78- #[ cfg( target_arch = "wasm32" ) ]
79- use std:: task:: Poll ;
75+ impl Timer {
76+ pub ( crate ) fn after ( dur : std:: time:: Duration ) -> Self {
77+ Timer ( futures_timer:: Delay :: new ( dur) )
78+ }
79+ }
8080
81- #[ cfg( target_arch = "wasm32" ) ]
82- impl std:: future:: Future for Timer {
83- type Output = ( ) ;
81+ impl std:: future:: Future for Timer {
82+ type Output = ( ) ;
8483
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 ( ( ) ) ,
84+ fn poll ( mut self : Pin < & mut Self > , cx : & mut std:: task:: Context < ' _ > ) -> Poll < Self :: Output > {
85+ match Pin :: new ( & mut self . 0 ) . poll ( cx) {
86+ Poll :: Pending => Poll :: Pending ,
87+ Poll :: Ready ( _) => Poll :: Ready ( ( ) ) ,
88+ }
8989 }
9090 }
9191}
9292
93+ pub ( crate ) use timer:: * ;
94+
9395/// Defers evaluation of a block of code until the end of the scope.
9496#[ cfg( feature = "default" ) ]
9597#[ doc( hidden) ]
0 commit comments