@@ -2,7 +2,6 @@ use super::display_buffer::DisplayBuffer;
22use crate :: cmp:: Ordering ;
33use crate :: fmt:: { self , Write } ;
44use crate :: hash:: { Hash , Hasher } ;
5- use crate :: iter;
65use crate :: mem:: transmute;
76use crate :: ops:: { BitAnd , BitAndAssign , BitOr , BitOrAssign , Not } ;
87
@@ -2348,20 +2347,24 @@ impl const From<[u16; 8]> for IpAddr {
23482347}
23492348
23502349#[ 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 {
23522352 type Output = Ipv4Addr ;
23532353
23542354 #[ inline]
23552355 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 ;
23582360 }
23592361 self
23602362 }
23612363}
23622364
23632365#[ 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 {
23652368 type Output = Ipv4Addr ;
23662369
23672370 #[ inline]
@@ -2371,20 +2374,24 @@ impl Not for &'_ Ipv4Addr {
23712374}
23722375
23732376#[ 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 {
23752379 type Output = Ipv6Addr ;
23762380
23772381 #[ inline]
23782382 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 ;
23812387 }
23822388 self
23832389 }
23842390}
23852391
23862392#[ 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 {
23882395 type Output = Ipv6Addr ;
23892396
23902397 #[ inline]
@@ -2400,23 +2407,25 @@ macro_rules! bitop_impls {
24002407 ) * ) => {
24012408 $(
24022409 $( #[ $attr] ) *
2403- impl $BitOpAssign for $ty {
2410+ impl const $BitOpAssign for $ty {
24042411 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 ;
24072416 }
24082417 }
24092418 }
24102419
24112420 $( #[ $attr] ) *
2412- impl $BitOpAssign<& ' _ $ty> for $ty {
2421+ impl const $BitOpAssign<& ' _ $ty> for $ty {
24132422 fn $bitop_assign( & mut self , rhs: & ' _ $ty) {
24142423 self . $bitop_assign( * rhs) ;
24152424 }
24162425 }
24172426
24182427 $( #[ $attr] ) *
2419- impl $BitOp for $ty {
2428+ impl const $BitOp for $ty {
24202429 type Output = $ty;
24212430
24222431 #[ inline]
@@ -2427,7 +2436,7 @@ macro_rules! bitop_impls {
24272436 }
24282437
24292438 $( #[ $attr] ) *
2430- impl $BitOp<& ' _ $ty> for $ty {
2439+ impl const $BitOp<& ' _ $ty> for $ty {
24312440 type Output = $ty;
24322441
24332442 #[ inline]
@@ -2438,7 +2447,7 @@ macro_rules! bitop_impls {
24382447 }
24392448
24402449 $( #[ $attr] ) *
2441- impl $BitOp<$ty> for & ' _ $ty {
2450+ impl const $BitOp<$ty> for & ' _ $ty {
24422451 type Output = $ty;
24432452
24442453 #[ inline]
@@ -2450,7 +2459,7 @@ macro_rules! bitop_impls {
24502459 }
24512460
24522461 $( #[ $attr] ) *
2453- impl $BitOp<& ' _ $ty> for & ' _ $ty {
2462+ impl const $BitOp<& ' _ $ty> for & ' _ $ty {
24542463 type Output = $ty;
24552464
24562465 #[ inline]
@@ -2466,12 +2475,16 @@ macro_rules! bitop_impls {
24662475
24672476bitop_impls ! {
24682477 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2478+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24692479 impl ( BitAnd , BitAndAssign ) for Ipv4Addr = ( bitand, bitand_assign) ;
24702480 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2481+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24712482 impl ( BitOr , BitOrAssign ) for Ipv4Addr = ( bitor, bitor_assign) ;
24722483
24732484 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2485+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24742486 impl ( BitAnd , BitAndAssign ) for Ipv6Addr = ( bitand, bitand_assign) ;
24752487 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2488+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24762489 impl ( BitOr , BitOrAssign ) for Ipv6Addr = ( bitor, bitor_assign) ;
24772490}
0 commit comments