@@ -1083,7 +1083,7 @@ fn render_memory_layout(
1083
1083
if config. niches {
1084
1084
if let Some ( niches) = layout. niches ( ) {
1085
1085
if niches > 1024 {
1086
- if is_pwr2 ( niches) {
1086
+ if niches. is_power_of_two ( ) {
1087
1087
format_to ! ( label, "niches = 2{}, " , pwr2_to_exponent( niches) ) ;
1088
1088
} else if is_pwr2plus1 ( niches) {
1089
1089
format_to ! ( label, "niches = 2{} + 1, " , pwr2_to_exponent( niches - 1 ) ) ;
@@ -1223,16 +1223,12 @@ fn render_dyn_compatibility(
1223
1223
}
1224
1224
}
1225
1225
1226
- fn is_pwr2 ( val : u128 ) -> bool {
1227
- val. is_power_of_two ( )
1228
- }
1229
-
1230
1226
fn is_pwr2minus1 ( val : u128 ) -> bool {
1231
- val == u128:: MAX || is_pwr2 ( val + 1 )
1227
+ val == u128:: MAX || ( val + 1 ) . is_power_of_two ( )
1232
1228
}
1233
1229
1234
1230
fn is_pwr2plus1 ( val : u128 ) -> bool {
1235
- val != 0 && is_pwr2 ( val - 1 )
1231
+ val != 0 && ( val - 1 ) . is_power_of_two ( )
1236
1232
}
1237
1233
1238
1234
/// Formats a power of two as an exponent of two, i.e. 16 => ⁴. Note that `num` MUST be a power
@@ -1254,16 +1250,6 @@ mod tests {
1254
1250
1255
1251
const TESTERS : [ u128 ; 10 ] = [ 0 , 1 , 2 , 3 , 4 , 255 , 256 , 257 , u128:: MAX - 1 , u128:: MAX ] ;
1256
1252
1257
- #[ test]
1258
- fn test_is_pwr2 ( ) {
1259
- const OUTCOMES : [ bool ; 10 ] =
1260
- [ false , true , true , false , true , false , true , false , false , false ] ;
1261
- for ( test, expected) in TESTERS . iter ( ) . zip ( OUTCOMES ) {
1262
- let actual = is_pwr2 ( * test) ;
1263
- assert_eq ! ( actual, expected, "is_pwr2({test}) gave {actual}, expected {expected}" ) ;
1264
- }
1265
- }
1266
-
1267
1253
#[ test]
1268
1254
fn test_is_pwr2minus1 ( ) {
1269
1255
const OUTCOMES : [ bool ; 10 ] =
0 commit comments