Resolve warnings in coordinates

This commit is contained in:
Savanni D'Gerinel 2023-10-04 16:09:41 -04:00
parent 7b6b7ec011
commit 5496e9ce10
4 changed files with 8 additions and 10 deletions

View File

@ -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::<usize>().ok())
.unwrap_or(3);
let map: hex_map::Map<MapVal> = hex_map::Map::new_hexagonal(size);
hex_map::write_file(filename, map);
hex_map::write_file(filename, map).expect("to write file");
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
/// Ĉ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::<Vec<AxialAddr>>()
.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) {

View File

@ -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<String>>(
}
let cells = data
.map(|line| parse_line::<A>(&line).unwrap())
.map(|line| parse_line::<A>(line).unwrap())
.collect::<Vec<(AxialAddr, A)>>();
let cells = cells.into_iter().collect::<HashMap<AxialAddr, A>>();
Map { cells }

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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),