24
24
/// ```{.rust}
25
25
/// bitflags! {
26
26
/// flags Flags: u32 {
27
- /// const FLAG_A = 0x00000001 ,
28
- /// const FLAG_B = 0x00000010 ,
29
- /// const FLAG_C = 0x00000100 ,
27
+ /// const FLAG_A = 0b00000001 ,
28
+ /// const FLAG_B = 0b00000010 ,
29
+ /// const FLAG_C = 0b00000100 ,
30
30
/// const FLAG_ABC = FLAG_A.bits
31
31
/// | FLAG_B.bits
32
32
/// | FLAG_C.bits,
50
50
///
51
51
/// bitflags! {
52
52
/// flags Flags: u32 {
53
- /// const FLAG_A = 0x00000001 ,
54
- /// const FLAG_B = 0x00000010 ,
53
+ /// const FLAG_A = 0b00000001 ,
54
+ /// const FLAG_B = 0b00000010 ,
55
55
/// }
56
56
/// }
57
57
///
@@ -326,10 +326,10 @@ mod tests {
326
326
#[ doc = "> " ]
327
327
#[ doc = "> - Richard Feynman" ]
328
328
flags Flags : u32 {
329
- const FlagA = 0x00000001 ,
329
+ const FlagA = 0b00000001 ,
330
330
#[ doc = "<pcwalton> macros are way better at generating code than trans is" ]
331
- const FlagB = 0x00000010 ,
332
- const FlagC = 0x00000100 ,
331
+ const FlagB = 0b00000010 ,
332
+ const FlagC = 0b00000100 ,
333
333
#[ doc = "* cmr bed" ]
334
334
#[ doc = "* strcat table" ]
335
335
#[ doc = "<strcat> wait what?" ]
@@ -347,33 +347,33 @@ mod tests {
347
347
348
348
#[ test]
349
349
fn test_bits ( ) {
350
- assert_eq ! ( Flags :: empty( ) . bits( ) , 0x00000000 ) ;
351
- assert_eq ! ( FlagA . bits( ) , 0x00000001 ) ;
352
- assert_eq ! ( FlagABC . bits( ) , 0x00000111 ) ;
350
+ assert_eq ! ( Flags :: empty( ) . bits( ) , 0b00000000 ) ;
351
+ assert_eq ! ( FlagA . bits( ) , 0b00000001 ) ;
352
+ assert_eq ! ( FlagABC . bits( ) , 0b00000111 ) ;
353
353
354
- assert_eq ! ( AnotherSetOfFlags :: empty( ) . bits( ) , 0x00 ) ;
354
+ assert_eq ! ( AnotherSetOfFlags :: empty( ) . bits( ) , 0b00 ) ;
355
355
assert_eq ! ( AnotherFlag . bits( ) , !0_i8 ) ;
356
356
}
357
357
358
358
#[ test]
359
359
fn test_from_bits ( ) {
360
360
assert ! ( Flags :: from_bits( 0 ) == Some ( Flags :: empty( ) ) ) ;
361
- assert ! ( Flags :: from_bits( 0x1 ) == Some ( FlagA ) ) ;
362
- assert ! ( Flags :: from_bits( 0x10 ) == Some ( FlagB ) ) ;
363
- assert ! ( Flags :: from_bits( 0x11 ) == Some ( FlagA | FlagB ) ) ;
364
- assert ! ( Flags :: from_bits( 0x1000 ) == None ) ;
361
+ assert ! ( Flags :: from_bits( 0b1 ) == Some ( FlagA ) ) ;
362
+ assert ! ( Flags :: from_bits( 0b10 ) == Some ( FlagB ) ) ;
363
+ assert ! ( Flags :: from_bits( 0b11 ) == Some ( FlagA | FlagB ) ) ;
364
+ assert ! ( Flags :: from_bits( 0b1000 ) == None ) ;
365
365
366
366
assert ! ( AnotherSetOfFlags :: from_bits( !0_i8 ) == Some ( AnotherFlag ) ) ;
367
367
}
368
368
369
369
#[ test]
370
370
fn test_from_bits_truncate ( ) {
371
371
assert ! ( Flags :: from_bits_truncate( 0 ) == Flags :: empty( ) ) ;
372
- assert ! ( Flags :: from_bits_truncate( 0x1 ) == FlagA ) ;
373
- assert ! ( Flags :: from_bits_truncate( 0x10 ) == FlagB ) ;
374
- assert ! ( Flags :: from_bits_truncate( 0x11 ) == ( FlagA | FlagB ) ) ;
375
- assert ! ( Flags :: from_bits_truncate( 0x1000 ) == Flags :: empty( ) ) ;
376
- assert ! ( Flags :: from_bits_truncate( 0x1001 ) == FlagA ) ;
372
+ assert ! ( Flags :: from_bits_truncate( 0b1 ) == FlagA ) ;
373
+ assert ! ( Flags :: from_bits_truncate( 0b10 ) == FlagB ) ;
374
+ assert ! ( Flags :: from_bits_truncate( 0b11 ) == ( FlagA | FlagB ) ) ;
375
+ assert ! ( Flags :: from_bits_truncate( 0b1000 ) == Flags :: empty( ) ) ;
376
+ assert ! ( Flags :: from_bits_truncate( 0b1001 ) == FlagA ) ;
377
377
378
378
assert ! ( AnotherSetOfFlags :: from_bits_truncate( 0_i8 ) == AnotherSetOfFlags :: empty( ) ) ;
379
379
}
0 commit comments