File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed
Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,15 @@ fn main() -> Result<(), String> {
1313 . ok_or ( "Second argument must be the IP address and mask in CIDR notation, e.g. 0.0.0.0/0 or ::/0" ) ?
1414 . parse ( )
1515 . unwrap ( ) ;
16- let ip_net = if cidr. contains ( ":" ) {
16+ let ip_net = if cidr. contains ( ':' ) {
1717 IpNetwork :: V6 ( cidr. parse ( ) . unwrap ( ) )
1818 } else {
1919 IpNetwork :: V4 ( cidr. parse ( ) . unwrap ( ) )
2020 } ;
2121
2222 let mut n = 0 ;
2323 let mut iter: Within < geoip2:: City , _ > = reader. within ( ip_net) . map_err ( |e| e. to_string ( ) ) ?;
24- while let Some ( next) = iter. next ( ) {
24+ for next in iter {
2525 let item = next. map_err ( |e| e. to_string ( ) ) ?;
2626 let continent = item. info . continent . and_then ( |c| c. code ) . unwrap_or ( "" ) ;
2727 let country = item. info . country . and_then ( |c| c. iso_code ) . unwrap_or ( "" ) ;
Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ impl<'de, S: AsRef<[u8]>> Reader<S> {
304304 // Traverse down the tree to the level that matches the cidr mark
305305 let mut i = 0_usize ;
306306 while i < prefix_len {
307- let bit = 1 & ( ip_bytes[ i >> 3 ] >> 7 - ( i % 8 ) ) as usize ;
307+ let bit = 1 & ( ip_bytes[ i >> 3 ] >> ( 7 - ( i % 8 ) ) ) as usize ;
308308 node = self . read_node ( node, bit) ?;
309309 if node >= node_count {
310310 // We've hit a dead end before we exhausted our prefix
Original file line number Diff line number Diff line change @@ -357,7 +357,7 @@ fn test_within_city() {
357357 assert_eq ! ( item. info. city. unwrap( ) . geoname_id, Some ( 2655045 ) ) ;
358358
359359 let mut n = 1 ;
360- while let Some ( _ ) = iter. next ( ) {
360+ for _ in iter {
361361 n += 1 ;
362362 }
363363
@@ -375,7 +375,7 @@ fn test_within_city() {
375375 IpNetwork :: V4 ( "81.2.69.144/28" . parse( ) . unwrap( ) ) ,
376376 IpNetwork :: V4 ( "81.2.69.142/31" . parse( ) . unwrap( ) ) ,
377377 ] ;
378- while expected. len ( ) > 0 {
378+ while ! expected. is_empty ( ) {
379379 let e = expected. pop ( ) . unwrap ( ) ;
380380 let item = iter. next ( ) . unwrap ( ) . unwrap ( ) ;
381381 assert_eq ! ( item. ip_net, e) ;
You can’t perform that action at this time.
0 commit comments