@@ -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
@@ -2337,20 +2336,24 @@ impl From<[u16; 8]> for IpAddr {
23372336}
23382337
23392338#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2340- impl Not for Ipv4Addr {
2339+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2340+ impl const Not for Ipv4Addr {
23412341 type Output = Ipv4Addr ;
23422342
23432343 #[ inline]
23442344 fn not ( mut self ) -> Ipv4Addr {
2345- for octet in & mut self . octets {
2346- * octet = !* octet;
2345+ let mut idx = 0 ;
2346+ while idx < 4 {
2347+ self . octets [ idx] = !self . octets [ idx] ;
2348+ idx += 1 ;
23472349 }
23482350 self
23492351 }
23502352}
23512353
23522354#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2353- impl Not for & ' _ Ipv4Addr {
2355+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2356+ impl const Not for & ' _ Ipv4Addr {
23542357 type Output = Ipv4Addr ;
23552358
23562359 #[ inline]
@@ -2360,20 +2363,24 @@ impl Not for &'_ Ipv4Addr {
23602363}
23612364
23622365#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2363- impl Not for Ipv6Addr {
2366+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2367+ impl const Not for Ipv6Addr {
23642368 type Output = Ipv6Addr ;
23652369
23662370 #[ inline]
23672371 fn not ( mut self ) -> Ipv6Addr {
2368- for octet in & mut self . octets {
2369- * octet = !* octet;
2372+ let mut idx = 0 ;
2373+ while idx < 16 {
2374+ self . octets [ idx] = !self . octets [ idx] ;
2375+ idx += 1 ;
23702376 }
23712377 self
23722378 }
23732379}
23742380
23752381#[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2376- impl Not for & ' _ Ipv6Addr {
2382+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
2383+ impl const Not for & ' _ Ipv6Addr {
23772384 type Output = Ipv6Addr ;
23782385
23792386 #[ inline]
@@ -2389,23 +2396,25 @@ macro_rules! bitop_impls {
23892396 ) * ) => {
23902397 $(
23912398 $( #[ $attr] ) *
2392- impl $BitOpAssign for $ty {
2399+ impl const $BitOpAssign for $ty {
23932400 fn $bitop_assign( & mut self , rhs: $ty) {
2394- for ( lhs, rhs) in iter:: zip( & mut self . octets, rhs. octets) {
2395- lhs. $bitop_assign( rhs) ;
2401+ let mut idx = 0 ;
2402+ while idx < self . octets. len( ) {
2403+ self . octets[ idx] . $bitop_assign( rhs. octets[ idx] ) ;
2404+ idx += 1 ;
23962405 }
23972406 }
23982407 }
23992408
24002409 $( #[ $attr] ) *
2401- impl $BitOpAssign<& ' _ $ty> for $ty {
2410+ impl const $BitOpAssign<& ' _ $ty> for $ty {
24022411 fn $bitop_assign( & mut self , rhs: & ' _ $ty) {
24032412 self . $bitop_assign( * rhs) ;
24042413 }
24052414 }
24062415
24072416 $( #[ $attr] ) *
2408- impl $BitOp for $ty {
2417+ impl const $BitOp for $ty {
24092418 type Output = $ty;
24102419
24112420 #[ inline]
@@ -2416,7 +2425,7 @@ macro_rules! bitop_impls {
24162425 }
24172426
24182427 $( #[ $attr] ) *
2419- impl $BitOp<& ' _ $ty> for $ty {
2428+ impl const $BitOp<& ' _ $ty> 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]
@@ -2439,7 +2448,7 @@ macro_rules! bitop_impls {
24392448 }
24402449
24412450 $( #[ $attr] ) *
2442- impl $BitOp<& ' _ $ty> for & ' _ $ty {
2451+ impl const $BitOp<& ' _ $ty> for & ' _ $ty {
24432452 type Output = $ty;
24442453
24452454 #[ inline]
@@ -2455,12 +2464,16 @@ macro_rules! bitop_impls {
24552464
24562465bitop_impls ! {
24572466 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2467+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24582468 impl ( BitAnd , BitAndAssign ) for Ipv4Addr = ( bitand, bitand_assign) ;
24592469 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2470+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24602471 impl ( BitOr , BitOrAssign ) for Ipv4Addr = ( bitor, bitor_assign) ;
24612472
24622473 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2474+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24632475 impl ( BitAnd , BitAndAssign ) for Ipv6Addr = ( bitand, bitand_assign) ;
24642476 #[ stable( feature = "ip_bitops" , since = "1.75.0" ) ]
2477+ #[ rustc_const_unstable( feature = "const_ops" , issue = "143802" ) ]
24652478 impl ( BitOr , BitOrAssign ) for Ipv6Addr = ( bitor, bitor_assign) ;
24662479}
0 commit comments