diff options
author | Micah Elizabeth Scott <beth@torproject.org> | 2023-08-14 13:04:51 -0700 |
---|---|---|
committer | Micah Elizabeth Scott <beth@torproject.org> | 2023-08-15 09:52:30 -0700 |
commit | 4ec193dcc5a71c6f1d501b011ce5b7407820dc34 (patch) | |
tree | 5f72e63ab0cb495075ae888c8ae866c297ada096 /scripts | |
parent | 00881f1886a18a7d203778e342e80037c32257b5 (diff) | |
download | tor-4ec193dcc5a71c6f1d501b011ce5b7407820dc34.tar.gz tor-4ec193dcc5a71c6f1d501b011ce5b7407820dc34.zip |
geoip-db-tool: Fix clippy warnings
This fixes warnings found by clippy 0.1.71 on Rust 1.71.1
Tested this by doing a geoip update without committing changes.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/maint/geoip/geoip-db-tool/src/db.rs | 16 | ||||
-rw-r--r-- | scripts/maint/geoip/geoip-db-tool/src/main.rs | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/scripts/maint/geoip/geoip-db-tool/src/db.rs b/scripts/maint/geoip/geoip-db-tool/src/db.rs index 316182d823..3d631a3f98 100644 --- a/scripts/maint/geoip/geoip-db-tool/src/db.rs +++ b/scripts/maint/geoip/geoip-db-tool/src/db.rs @@ -13,9 +13,9 @@ where } pub enum AnyBlock { - NetBlock(NetBlock), - AsBlock(AsBlock), - OtherBlock, + Net(NetBlock), + As(AsBlock), + Other, } impl<I> BlockReader<I> @@ -50,13 +50,13 @@ where fn get_block(&mut self) -> Option<std::io::Result<AnyBlock>> { let mut kv = HashMap::new(); - while let Some(line) = self.iter.next() { + for line in self.iter.by_ref() { //dbg!(&line); if let Err(e) = line { return Some(Err(e)); } let line_orig = line.unwrap(); - let line = line_orig.splitn(2, '#').next().unwrap().trim(); + let line = line_orig.split('#').next().unwrap().trim(); if line.is_empty() { if kv.is_empty() { continue; @@ -80,13 +80,13 @@ where let asn = kv.get("aut-num").unwrap(); // XXXX handle error better assert!(asn.starts_with("AS")); let asn = asn[2..].parse().unwrap(); - return Some(Ok(AnyBlock::AsBlock(AsBlock { name, asn }))); + return Some(Ok(AnyBlock::As(AsBlock { name, asn }))); } let net = if let Some(net) = kv.get("net") { net.parse().unwrap() //XXXX handle the error better. } else { - return Some(Ok(AnyBlock::OtherBlock)); + return Some(Ok(AnyBlock::Other)); }; let asn = if let Some(asn) = kv.get("aut-num") { @@ -113,7 +113,7 @@ where let is_anycast = is_true(kv.get("is-anycast-proxy")); let is_satellite = is_true(kv.get("is-satellite-provider")); - Some(Ok(AnyBlock::NetBlock(NetBlock { + Some(Ok(AnyBlock::Net(NetBlock { net, asn, cc, diff --git a/scripts/maint/geoip/geoip-db-tool/src/main.rs b/scripts/maint/geoip/geoip-db-tool/src/main.rs index b255981aae..cbadd6623f 100644 --- a/scripts/maint/geoip/geoip-db-tool/src/main.rs +++ b/scripts/maint/geoip/geoip-db-tool/src/main.rs @@ -152,8 +152,8 @@ fn convert(args: Args) -> std::io::Result<()> { // Read blocks, and then sort them by specificity and address. for nb in reader { match nb { - db::AnyBlock::AsBlock(a) => networks.push(a), - db::AnyBlock::NetBlock(n) => blocks.push(n), + db::AnyBlock::As(a) => networks.push(a), + db::AnyBlock::Net(n) => blocks.push(n), _ => {} } } |