@@ -184,10 +184,16 @@ const INITIALIZING: usize = 1;
184184const INITIALIZED : usize = 2 ;
185185
186186static mut GLOBAL_DISPATCH : Dispatch = Dispatch {
187+ #[ cfg( feature = "std" ) ]
187188 subscriber : Kind :: Global ( & NO_SUBSCRIBER ) ,
189+ #[ cfg( not( feature = "std" ) ) ]
190+ subscriber : & NO_SUBSCRIBER ,
188191} ;
189192static NONE : Dispatch = Dispatch {
193+ #[ cfg( feature = "std" ) ]
190194 subscriber : Kind :: Global ( & NO_SUBSCRIBER ) ,
195+ #[ cfg( not( feature = "std" ) ) ]
196+ subscriber : & NO_SUBSCRIBER ,
191197} ;
192198static NO_SUBSCRIBER : NoSubscriber = NoSubscriber ;
193199
@@ -396,34 +402,34 @@ where
396402 . unwrap_or_else ( |_| f ( & Dispatch :: none ( ) ) )
397403}
398404
399- /// Executes a closure with a reference to this thread's current [dispatcher].
400- ///
401- /// Note that calls to `get_default` should not be nested; if this function is
402- /// called while inside of another `get_default`, that closure will be provided
403- /// with `Dispatch::none` rather than the previously set dispatcher.
404- ///
405- /// [dispatcher]: super::dispatcher::Dispatch
406- #[ cfg( feature = "std" ) ]
407- #[ doc( hidden) ]
408- #[ inline( never) ]
409- pub fn get_current < T > ( f : impl FnOnce ( & Dispatch ) -> T ) -> Option < T > {
410- CURRENT_STATE
411- . try_with ( |state| {
412- let entered = state. enter ( ) ?;
413- Some ( f ( & * entered. current ( ) ) )
414- } )
415- . ok ( ) ?
416- }
417-
418- /// Executes a closure with a reference to the current [dispatcher].
419- ///
420- /// [dispatcher]: super::dispatcher::Dispatch
421- #[ cfg( not( feature = "std" ) ) ]
422- #[ doc( hidden) ]
423- pub fn get_current < T > ( f : impl FnOnce ( & Dispatch ) -> T ) -> Option < T > {
424- let dispatch = get_global ( ) ?;
425- Some ( f ( & dispatch) )
426- }
405+ // // / Executes a closure with a reference to this thread's current [dispatcher].
406+ // // /
407+ // // / Note that calls to `get_default` should not be nested; if this function is
408+ // // / called while inside of another `get_default`, that closure will be provided
409+ // // / with `Dispatch::none` rather than the previously set dispatcher.
410+ // // /
411+ // // / [dispatcher]: super::dispatcher::Dispatch
412+ // #[cfg(feature = "std")]
413+ // #[doc(hidden)]
414+ // #[inline(never)]
415+ // pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
416+ // CURRENT_STATE
417+ // .try_with(|state| {
418+ // let entered = state.enter()?;
419+ // Some(f(&*entered.current()))
420+ // })
421+ // .ok()?
422+ // }
423+
424+ // // / Executes a closure with a reference to the current [dispatcher].
425+ // // /
426+ // // / [dispatcher]: super::dispatcher::Dispatch
427+ // #[cfg(not(feature = "std"))]
428+ // #[doc(hidden)]
429+ // pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
430+ // let dispatch = get_global()?;
431+ // Some(f(&dispatch))
432+ // }
427433
428434/// Executes a closure with a reference to the current [dispatcher].
429435///
@@ -752,6 +758,7 @@ impl fmt::Debug for Dispatch {
752758 }
753759}
754760
761+ #[ cfg( feature = "std" ) ]
755762impl < S > From < S > for Dispatch
756763where
757764 S : Subscriber + Send + Sync + ' static ,
@@ -788,6 +795,7 @@ impl Subscriber for NoSubscriber {
788795 fn exit ( & self , _span : & span:: Id ) { }
789796}
790797
798+ #[ cfg( feature = "std" ) ]
791799impl Registrar {
792800 pub ( crate ) fn upgrade ( & self ) -> Option < Dispatch > {
793801 match self . 0 {
@@ -889,13 +897,13 @@ mod test {
889897
890898 #[ test]
891899 fn dispatch_is ( ) {
892- let dispatcher = Dispatch :: new ( NoSubscriber ) ;
900+ let dispatcher = Dispatch :: from_static ( & NO_SUBSCRIBER ) ;
893901 assert ! ( dispatcher. is:: <NoSubscriber >( ) ) ;
894902 }
895903
896904 #[ test]
897905 fn dispatch_downcasts ( ) {
898- let dispatcher = Dispatch :: new ( NoSubscriber ) ;
906+ let dispatcher = Dispatch :: from_static ( & NO_SUBSCRIBER ) ;
899907 assert ! ( dispatcher. downcast_ref:: <NoSubscriber >( ) . is_some( ) ) ;
900908 }
901909
0 commit comments