@@ -2,7 +2,6 @@ use super::display_buffer::DisplayBuffer;
2
2
use crate :: cmp:: Ordering ;
3
3
use crate :: fmt:: { self , Write } ;
4
4
use crate :: hash:: { Hash , Hasher } ;
5
- use crate :: iter;
6
5
use crate :: mem:: transmute;
7
6
use crate :: ops:: { BitAnd , BitAndAssign , BitOr , BitOrAssign , Not } ;
8
7
@@ -2348,20 +2347,24 @@ impl const From<[u16; 8]> for IpAddr {
2348
2347
}
2349
2348
2350
2349
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2351
- impl Not for Ipv4Addr {
2350
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2351
+ impl const Not for Ipv4Addr {
2352
2352
type Output = Ipv4Addr ;
2353
2353
2354
2354
#[ inline]
2355
2355
fn not ( mut self ) -> Ipv4Addr {
2356
- for octet in & mut self . octets {
2357
- * octet = !* octet;
2356
+ let mut idx = 0 ;
2357
+ while idx < 4 {
2358
+ self . octets [ idx] = !self . octets [ idx] ;
2359
+ idx += 1 ;
2358
2360
}
2359
2361
self
2360
2362
}
2361
2363
}
2362
2364
2363
2365
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2364
- impl Not for & ' _ Ipv4Addr {
2366
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2367
+ impl const Not for & ' _ Ipv4Addr {
2365
2368
type Output = Ipv4Addr ;
2366
2369
2367
2370
#[ inline]
@@ -2371,20 +2374,24 @@ impl Not for &'_ Ipv4Addr {
2371
2374
}
2372
2375
2373
2376
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2374
- impl Not for Ipv6Addr {
2377
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2378
+ impl const Not for Ipv6Addr {
2375
2379
type Output = Ipv6Addr ;
2376
2380
2377
2381
#[ inline]
2378
2382
fn not ( mut self ) -> Ipv6Addr {
2379
- for octet in & mut self . octets {
2380
- * octet = !* octet;
2383
+ let mut idx = 0 ;
2384
+ while idx < 16 {
2385
+ self . octets [ idx] = !self . octets [ idx] ;
2386
+ idx += 1 ;
2381
2387
}
2382
2388
self
2383
2389
}
2384
2390
}
2385
2391
2386
2392
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2387
- impl Not for & ' _ Ipv6Addr {
2393
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2394
+ impl const Not for & ' _ Ipv6Addr {
2388
2395
type Output = Ipv6Addr ;
2389
2396
2390
2397
#[ inline]
@@ -2400,23 +2407,25 @@ macro_rules! bitop_impls {
2400
2407
) * ) => {
2401
2408
$(
2402
2409
$( #[ $attr] ) *
2403
- impl $BitOpAssign for $ty {
2410
+ impl const $BitOpAssign for $ty {
2404
2411
fn $bitop_assign( & mut self , rhs: $ty) {
2405
- for ( lhs, rhs) in iter:: zip( & mut self . octets, rhs. octets) {
2406
- lhs. $bitop_assign( rhs) ;
2412
+ let mut idx = 0 ;
2413
+ while idx < self . octets. len( ) {
2414
+ self . octets[ idx] . $bitop_assign( rhs. octets[ idx] ) ;
2415
+ idx += 1 ;
2407
2416
}
2408
2417
}
2409
2418
}
2410
2419
2411
2420
$( #[ $attr] ) *
2412
- impl $BitOpAssign<& ' _ $ty> for $ty {
2421
+ impl const $BitOpAssign<& ' _ $ty> for $ty {
2413
2422
fn $bitop_assign( & mut self , rhs: & ' _ $ty) {
2414
2423
self . $bitop_assign( * rhs) ;
2415
2424
}
2416
2425
}
2417
2426
2418
2427
$( #[ $attr] ) *
2419
- impl $BitOp for $ty {
2428
+ impl const $BitOp for $ty {
2420
2429
type Output = $ty;
2421
2430
2422
2431
#[ inline]
@@ -2427,7 +2436,7 @@ macro_rules! bitop_impls {
2427
2436
}
2428
2437
2429
2438
$( #[ $attr] ) *
2430
- impl $BitOp<& ' _ $ty> for $ty {
2439
+ impl const $BitOp<& ' _ $ty> for $ty {
2431
2440
type Output = $ty;
2432
2441
2433
2442
#[ inline]
@@ -2438,7 +2447,7 @@ macro_rules! bitop_impls {
2438
2447
}
2439
2448
2440
2449
$( #[ $attr] ) *
2441
- impl $BitOp<$ty> for & ' _ $ty {
2450
+ impl const $BitOp<$ty> for & ' _ $ty {
2442
2451
type Output = $ty;
2443
2452
2444
2453
#[ inline]
@@ -2450,7 +2459,7 @@ macro_rules! bitop_impls {
2450
2459
}
2451
2460
2452
2461
$( #[ $attr] ) *
2453
- impl $BitOp<& ' _ $ty> for & ' _ $ty {
2462
+ impl const $BitOp<& ' _ $ty> for & ' _ $ty {
2454
2463
type Output = $ty;
2455
2464
2456
2465
#[ inline]
@@ -2466,12 +2475,16 @@ macro_rules! bitop_impls {
2466
2475
2467
2476
bitop_impls ! {
2468
2477
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2478
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2469
2479
impl ( BitAnd , BitAndAssign ) for Ipv4Addr = ( bitand, bitand_assign) ;
2470
2480
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2481
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2471
2482
impl ( BitOr , BitOrAssign ) for Ipv4Addr = ( bitor, bitor_assign) ;
2472
2483
2473
2484
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2485
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2474
2486
impl ( BitAnd , BitAndAssign ) for Ipv6Addr = ( bitand, bitand_assign) ;
2475
2487
#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2488
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2476
2489
impl ( BitOr , BitOrAssign ) for Ipv6Addr = ( bitor, bitor_assign) ;
2477
2490
}
0 commit comments