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