@@ -4,28 +4,26 @@ use std::process;
44
55fn ip_reverse ( ip : & IpAddr ) -> String {
66 match ip {
7- IpAddr :: V4 ( ip4) => ip4_reverse ( ip4, "in-addr.arpa" ) ,
8- IpAddr :: V6 ( ip6) => ip6_reverse ( ip6, "ip6.arpa" ) ,
7+ IpAddr :: V4 ( ip4) => ip4_reverse ( ip4) ,
8+ IpAddr :: V6 ( ip6) => ip6_reverse ( ip6) ,
99 }
1010}
1111
12- fn ip4_reverse ( ip : & Ipv4Addr , suffix : & str ) -> String {
13- let mut rev = String :: with_capacity ( 16 + suffix . len ( ) ) ;
12+ fn ip4_reverse ( ip : & Ipv4Addr ) -> String {
13+ let mut rev = String :: with_capacity ( 16 ) ;
1414 for oct in ip. octets ( ) . iter ( ) . rev ( ) {
1515 rev. push_str ( format ! ( "{}." , oct) . as_str ( ) ) ;
1616 }
17- rev. push_str ( suffix) ;
1817 rev
1918}
2019
21- fn ip6_reverse ( ip : & Ipv6Addr , suffix : & str ) -> String {
22- let mut rev = String :: with_capacity ( 64 + suffix . len ( ) ) ;
20+ fn ip6_reverse ( ip : & Ipv6Addr ) -> String {
21+ let mut rev = String :: with_capacity ( 64 ) ;
2322 for oct in ip. octets ( ) . iter ( ) . rev ( ) {
2423 rev. push_str ( format ! ( "{:x}." , oct & 0x0fu8 ) . as_str ( ) ) ;
2524 // Rust gets mad about right-shifting set bits, so we need to mask + shift
2625 rev. push_str ( format ! ( "{:x}." , ( oct & 0xf0u8 ) >> 4u8 ) . as_str ( ) ) ;
2726 }
28- rev. push_str ( suffix) ;
2927 rev
3028}
3129
0 commit comments