@@ -183,10 +183,16 @@ const INITIALIZING: usize = 1;
183183const INITIALIZED : usize = 2 ;
184184
185185static mut GLOBAL_DISPATCH : Dispatch = Dispatch {
186+ #[ cfg( feature = "std" ) ]
186187 subscriber : Kind :: Global ( & NO_SUBSCRIBER ) ,
188+ #[ cfg( not( feature = "std" ) ) ]
189+ subscriber : & NO_SUBSCRIBER ,
187190} ;
188191static NONE : Dispatch = Dispatch {
192+ #[ cfg( feature = "std" ) ]
189193 subscriber : Kind :: Global ( & NO_SUBSCRIBER ) ,
194+ #[ cfg( not( feature = "std" ) ) ]
195+ subscriber : & NO_SUBSCRIBER ,
190196} ;
191197static NO_SUBSCRIBER : NoSubscriber = NoSubscriber ;
192198
@@ -395,34 +401,34 @@ where
395401 . unwrap_or_else ( |_| f ( & Dispatch :: none ( ) ) )
396402}
397403
398- /// Executes a closure with a reference to this thread's current [dispatcher].
399- ///
400- /// Note that calls to `get_default` should not be nested; if this function is
401- /// called while inside of another `get_default`, that closure will be provided
402- /// with `Dispatch::none` rather than the previously set dispatcher.
403- ///
404- /// [dispatcher]: super::dispatcher::Dispatch
405- #[ cfg( feature = "std" ) ]
406- #[ doc( hidden) ]
407- #[ inline( never) ]
408- pub fn get_current < T > ( f : impl FnOnce ( & Dispatch ) -> T ) -> Option < T > {
409- CURRENT_STATE
410- . try_with ( |state| {
411- let entered = state. enter ( ) ?;
412- Some ( f ( & * entered. current ( ) ) )
413- } )
414- . ok ( ) ?
415- }
416-
417- /// Executes a closure with a reference to the current [dispatcher].
418- ///
419- /// [dispatcher]: super::dispatcher::Dispatch
420- #[ cfg( not( feature = "std" ) ) ]
421- #[ doc( hidden) ]
422- pub fn get_current < T > ( f : impl FnOnce ( & Dispatch ) -> T ) -> Option < T > {
423- let dispatch = get_global ( ) ?;
424- Some ( f ( & dispatch) )
425- }
404+ // // / Executes a closure with a reference to this thread's current [dispatcher].
405+ // // /
406+ // // / Note that calls to `get_default` should not be nested; if this function is
407+ // // / called while inside of another `get_default`, that closure will be provided
408+ // // / with `Dispatch::none` rather than the previously set dispatcher.
409+ // // /
410+ // // / [dispatcher]: super::dispatcher::Dispatch
411+ // #[cfg(feature = "std")]
412+ // #[doc(hidden)]
413+ // #[inline(never)]
414+ // pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
415+ // CURRENT_STATE
416+ // .try_with(|state| {
417+ // let entered = state.enter()?;
418+ // Some(f(&*entered.current()))
419+ // })
420+ // .ok()?
421+ // }
422+
423+ // // / Executes a closure with a reference to the current [dispatcher].
424+ // // /
425+ // // / [dispatcher]: super::dispatcher::Dispatch
426+ // #[cfg(not(feature = "std"))]
427+ // #[doc(hidden)]
428+ // pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
429+ // let dispatch = get_global()?;
430+ // Some(f(&dispatch))
431+ // }
426432
427433/// Executes a closure with a reference to the current [dispatcher].
428434///
@@ -751,6 +757,7 @@ impl fmt::Debug for Dispatch {
751757 }
752758}
753759
760+ #[ cfg( feature = "std" ) ]
754761impl < S > From < S > for Dispatch
755762where
756763 S : Subscriber + Send + Sync + ' static ,
@@ -787,6 +794,7 @@ impl Subscriber for NoSubscriber {
787794 fn exit ( & self , _span : & span:: Id ) { }
788795}
789796
797+ #[ cfg( feature = "std" ) ]
790798impl Registrar {
791799 pub ( crate ) fn upgrade ( & self ) -> Option < Dispatch > {
792800 match self . 0 {
@@ -890,13 +898,13 @@ mod test {
890898
891899 #[ test]
892900 fn dispatch_is ( ) {
893- let dispatcher = Dispatch :: new ( NoSubscriber ) ;
901+ let dispatcher = Dispatch :: from_static ( & NO_SUBSCRIBER ) ;
894902 assert ! ( dispatcher. is:: <NoSubscriber >( ) ) ;
895903 }
896904
897905 #[ test]
898906 fn dispatch_downcasts ( ) {
899- let dispatcher = Dispatch :: new ( NoSubscriber ) ;
907+ let dispatcher = Dispatch :: from_static ( & NO_SUBSCRIBER ) ;
900908 assert ! ( dispatcher. downcast_ref:: <NoSubscriber >( ) . is_some( ) ) ;
901909 }
902910
0 commit comments