From 5496e9ce10f6d62de7baf71d0fbca779dba03384 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 4 Oct 2023 16:09:41 -0400 Subject: [PATCH] Resolve warnings in coordinates --- coordinates/src/bin/default_map.rs | 4 ++-- coordinates/src/hex.rs | 7 +++---- coordinates/src/hex_map.rs | 3 +-- coordinates/src/lib.rs | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/coordinates/src/bin/default_map.rs b/coordinates/src/bin/default_map.rs index b5f6ba4..356720d 100644 --- a/coordinates/src/bin/default_map.rs +++ b/coordinates/src/bin/default_map.rs @@ -33,12 +33,12 @@ fn main() { let filename = args .next() - .map(|p| PathBuf::from(p)) + .map(PathBuf::from) .expect("A filename is required"); let size = args .next() .and_then(|s| s.parse::().ok()) .unwrap_or(3); let map: hex_map::Map = hex_map::Map::new_hexagonal(size); - hex_map::write_file(filename, map); + hex_map::write_file(filename, map).expect("to write file"); } diff --git a/coordinates/src/hex.rs b/coordinates/src/hex.rs index d3b9880..d11b3a7 100644 --- a/coordinates/src/hex.rs +++ b/coordinates/src/hex.rs @@ -10,10 +10,9 @@ Luminescent Dreams Tools is distributed in the hope that it will be useful, but You should have received a copy of the GNU General Public License along with Lumeto. If not, see . */ -/// Ĉi-tiu modulo enhavas la elementojn por kub-koordinato. +/// This module contains the elements of cube coordinates. /// /// This code is based on https://www.redblobgames.com/grids/hexagons/ -use crate::Error; use std::collections::HashSet; /// An address within the hex coordinate system @@ -62,7 +61,7 @@ impl AxialAddr { pub fn is_adjacent(&self, dest: &AxialAddr) -> bool { dest.adjacencies() .collect::>() - .contains(&self) + .contains(self) } /// Measure the distance to a destination @@ -79,7 +78,7 @@ impl AxialAddr { positions.push(item); - while positions.len() > 0 { + while !positions.is_empty() { let elem = positions.remove(0); for adj in elem.adjacencies() { if self.distance(&adj) <= distance && !results.contains(&adj) { diff --git a/coordinates/src/hex_map.rs b/coordinates/src/hex_map.rs index 72ff9cc..76e9eab 100644 --- a/coordinates/src/hex_map.rs +++ b/coordinates/src/hex_map.rs @@ -14,7 +14,6 @@ use crate::{hex::AxialAddr, Error}; use nom::{ bytes::complete::tag, character::complete::alphanumeric1, - error::ParseError, multi::many1, sequence::{delimited, separated_pair}, Finish, IResult, Parser, @@ -81,7 +80,7 @@ pub fn parse_data<'a, A: Default + From>( } let cells = data - .map(|line| parse_line::(&line).unwrap()) + .map(|line| parse_line::(line).unwrap()) .collect::>(); let cells = cells.into_iter().collect::>(); Map { cells } diff --git a/coordinates/src/lib.rs b/coordinates/src/lib.rs index 52c337c..6d591ad 100644 --- a/coordinates/src/lib.rs +++ b/coordinates/src/lib.rs @@ -9,9 +9,9 @@ Lumeto is distributed in the hope that it will be useful, but WITHOUT ANY WARRAN You should have received a copy of the GNU General Public License along with Lumeto. If not, see . */ -use thiserror; +use thiserror::Error; -#[derive(Debug, thiserror::Error)] +#[derive(Debug, Error)] pub enum Error { #[error("IO error on reading or writing: {0}")] IO(std::io::Error),