55use crate :: any:: Any ;
66use crate :: collections;
77use crate :: panicking;
8- use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
8+ use crate :: sync:: atomic:: { AtomicU8 , Ordering } ;
99use crate :: sync:: { Mutex , RwLock } ;
1010use crate :: thread:: Result ;
1111
@@ -228,15 +228,15 @@ impl BacktraceStyle {
228228 if cfg ! ( feature = "backtrace" ) { Some ( BacktraceStyle :: Full ) } else { None }
229229 }
230230
231- fn as_usize ( self ) -> usize {
231+ fn as_u8 ( self ) -> u8 {
232232 match self {
233233 BacktraceStyle :: Short => 1 ,
234234 BacktraceStyle :: Full => 2 ,
235235 BacktraceStyle :: Off => 3 ,
236236 }
237237 }
238238
239- fn from_usize ( s : usize ) -> Option < Self > {
239+ fn from_u8 ( s : u8 ) -> Option < Self > {
240240 Some ( match s {
241241 0 => return None ,
242242 1 => BacktraceStyle :: Short ,
@@ -251,7 +251,7 @@ impl BacktraceStyle {
251251// that backtrace.
252252//
253253// Internally stores equivalent of an Option<BacktraceStyle>.
254- static SHOULD_CAPTURE : AtomicUsize = AtomicUsize :: new ( 0 ) ;
254+ static SHOULD_CAPTURE : AtomicU8 = AtomicU8 :: new ( 0 ) ;
255255
256256/// Configure whether the default panic hook will capture and display a
257257/// backtrace.
@@ -264,7 +264,7 @@ pub fn set_backtrace_style(style: BacktraceStyle) {
264264 // If the `backtrace` feature of this crate isn't enabled, skip setting.
265265 return ;
266266 }
267- SHOULD_CAPTURE . store ( style. as_usize ( ) , Ordering :: Release ) ;
267+ SHOULD_CAPTURE . store ( style. as_u8 ( ) , Ordering :: Release ) ;
268268}
269269
270270/// Checks whether the standard library's panic hook will capture and print a
@@ -296,7 +296,7 @@ pub fn get_backtrace_style() -> Option<BacktraceStyle> {
296296 // to optimize away callers.
297297 return None ;
298298 }
299- if let Some ( style) = BacktraceStyle :: from_usize ( SHOULD_CAPTURE . load ( Ordering :: Acquire ) ) {
299+ if let Some ( style) = BacktraceStyle :: from_u8 ( SHOULD_CAPTURE . load ( Ordering :: Acquire ) ) {
300300 return Some ( style) ;
301301 }
302302
0 commit comments