Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgrunewald committed Jul 25, 2024
1 parent beb6f39 commit ac32943
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
8 changes: 6 additions & 2 deletions generator/src/countries.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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};
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
Expand Down
1 change: 1 addition & 0 deletions generator/src/country_map.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion generator/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion generator/src/regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ pub fn read_geojson<P: AsRef<path::Path>>(file: P) -> Result<Geometry> {

pub fn to_cells(geometry: Geometry, resolution: Resolution) -> Result<Vec<CellIndex>> {
let collection = geometry
.to_cells(
PolyfillConfig::new(resolution)
.containment_mode(ContainmentMode::Covers)
);
.to_cells(PolyfillConfig::new(resolution).containment_mode(ContainmentMode::Covers));
Ok(collection.collect())
}

Expand Down Expand Up @@ -116,6 +113,7 @@ pub fn write_geojson<P: AsRef<path::Path>>(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(())
Expand Down

0 comments on commit ac32943

Please sign in to comment.