From ac32943447589259a3c94cc4cb5166af1e500444 Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Thu, 25 Jul 2024 15:27:44 -0400 Subject: [PATCH] fix lints --- generator/src/countries.rs | 8 ++++++-- generator/src/country_map.rs | 1 + generator/src/index.rs | 2 +- generator/src/regions.rs | 2 +- generator/src/utils.rs | 6 ++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/generator/src/countries.rs b/generator/src/countries.rs index e9d2f13..48a676e 100644 --- a/generator/src/countries.rs +++ b/generator/src/countries.rs @@ -1,4 +1,4 @@ -use crate::{print_json, country_map::Country, utils::*}; +use crate::{country_map::Country, print_json, utils::*}; use anyhow::Result; use byteorder::ReadBytesExt; use h3o::{CellIndex, Resolution}; @@ -6,7 +6,11 @@ use hextree::{compaction::EqCompactor, Cell, HexTreeMap}; use isocountry::CountryCode; use rayon::prelude::*; use std::{ - collections::HashMap, fs::File, io::{Cursor, Write}, path, sync::{Arc, Mutex} + collections::HashMap, + fs::File, + io::{Cursor, Write}, + path, + sync::{Arc, Mutex}, }; /// Commands on region indexes diff --git a/generator/src/country_map.rs b/generator/src/country_map.rs index 6c4afe6..98d3571 100644 --- a/generator/src/country_map.rs +++ b/generator/src/country_map.rs @@ -1,5 +1,6 @@ use isocountry::CountryCode; +#[allow(clippy::upper_case_acronyms)] #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[repr(u8)] pub enum Country { diff --git a/generator/src/index.rs b/generator/src/index.rs index b0c9e1d..a36f589 100644 --- a/generator/src/index.rs +++ b/generator/src/index.rs @@ -102,7 +102,7 @@ impl Find { let hex_set = read_hexset(&path)?; for (name, needle) in &needles { if hex_set.contains(*needle) { - let match_list = matches.entry(name.to_string()).or_insert(vec![]); + let match_list = matches.entry(name.to_string()).or_default(); // Avoid duplicate path entries if the same location is // specified multiple times diff --git a/generator/src/regions.rs b/generator/src/regions.rs index e938b02..8586add 100644 --- a/generator/src/regions.rs +++ b/generator/src/regions.rs @@ -102,7 +102,7 @@ impl Find { let hex_set = read_hexset(&path)?; for (name, needle) in &needles { if hex_set.contains(*needle) { - let match_list = matches.entry(name.to_string()).or_insert(vec![]); + let match_list = matches.entry(name.to_string()).or_default(); // Avoid duplicate path entries if the same location is // specified multiple times diff --git a/generator/src/utils.rs b/generator/src/utils.rs index 555339b..2aeed90 100644 --- a/generator/src/utils.rs +++ b/generator/src/utils.rs @@ -17,10 +17,7 @@ pub fn read_geojson>(file: P) -> Result { pub fn to_cells(geometry: Geometry, resolution: Resolution) -> Result> { let collection = geometry - .to_cells( - PolyfillConfig::new(resolution) - .containment_mode(ContainmentMode::Covers) - ); + .to_cells(PolyfillConfig::new(resolution).containment_mode(ContainmentMode::Covers)); Ok(collection.collect()) } @@ -116,6 +113,7 @@ pub fn write_geojson>(geojson: GeoJson, output: P) -> Resul let mut writer = fs::OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(output.as_ref())?; writer.write_all(geojson.to_string().as_bytes())?; Ok(())