5
5
use crate :: any:: Any ;
6
6
use crate :: collections;
7
7
use crate :: panicking;
8
- use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
8
+ use crate :: sync:: atomic:: { AtomicU8 , Ordering } ;
9
9
use crate :: sync:: { Mutex , RwLock } ;
10
10
use crate :: thread:: Result ;
11
11
@@ -228,15 +228,15 @@ impl BacktraceStyle {
228
228
if cfg ! ( feature = "backtrace" ) { Some ( BacktraceStyle :: Full ) } else { None }
229
229
}
230
230
231
- fn as_usize ( self ) -> usize {
231
+ fn as_u8 ( self ) -> u8 {
232
232
match self {
233
233
BacktraceStyle :: Short => 1 ,
234
234
BacktraceStyle :: Full => 2 ,
235
235
BacktraceStyle :: Off => 3 ,
236
236
}
237
237
}
238
238
239
- fn from_usize ( s : usize ) -> Option < Self > {
239
+ fn from_u8 ( s : u8 ) -> Option < Self > {
240
240
Some ( match s {
241
241
0 => return None ,
242
242
1 => BacktraceStyle :: Short ,
@@ -251,7 +251,7 @@ impl BacktraceStyle {
251
251
// that backtrace.
252
252
//
253
253
// Internally stores equivalent of an Option<BacktraceStyle>.
254
- static SHOULD_CAPTURE : AtomicUsize = AtomicUsize :: new ( 0 ) ;
254
+ static SHOULD_CAPTURE : AtomicU8 = AtomicU8 :: new ( 0 ) ;
255
255
256
256
/// Configure whether the default panic hook will capture and display a
257
257
/// backtrace.
@@ -264,7 +264,7 @@ pub fn set_backtrace_style(style: BacktraceStyle) {
264
264
// If the `backtrace` feature of this crate isn't enabled, skip setting.
265
265
return ;
266
266
}
267
- SHOULD_CAPTURE . store ( style. as_usize ( ) , Ordering :: Release ) ;
267
+ SHOULD_CAPTURE . store ( style. as_u8 ( ) , Ordering :: Release ) ;
268
268
}
269
269
270
270
/// Checks whether the standard library's panic hook will capture and print a
@@ -296,7 +296,7 @@ pub fn get_backtrace_style() -> Option<BacktraceStyle> {
296
296
// to optimize away callers.
297
297
return None ;
298
298
}
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 ) ) {
300
300
return Some ( style) ;
301
301
}
302
302
0 commit comments