Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
wainwrightmark committed Nov 12, 2024
1 parent 9a64df4 commit 94f8918
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
4 changes: 1 addition & 3 deletions benches/my_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ fn bench_tile_set_64_nth() -> u64 {
let set = black_box(TileSet64::<8, 8, 64>::ALL);

(0..64)
.into_iter()
.map(|n| set.iter_true_tiles().nth(n))
.flatten()
.filter_map(|n| set.iter_true_tiles().nth(n))
.map(|x| x.inner() as u64)
.sum()
}
Expand Down
4 changes: 2 additions & 2 deletions src/tile_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ impl<T, const WIDTH: u8, const HEIGHT: u8, const SIZE: usize> TileMap<T, WIDTH,
/// Get the scale to make the grid take up as much as possible of a given area
#[must_use]
pub fn get_scale(total_width: f32, total_height: f32) -> f32 {
let x_multiplier = total_width / WIDTH as f32;
let y_multiplier = total_height / HEIGHT as f32;
let x_multiplier = total_width / f32::from(WIDTH);
let y_multiplier = total_height / f32::from(HEIGHT);

x_multiplier.min(y_multiplier)
}
Expand Down
2 changes: 1 addition & 1 deletion src/tile_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ mod tests {
let scale_rect = Grid::get_scale(100.0, 50.0);

assert_eq!(scale_square, 25.0);
assert_eq!(scale_rect, 16.666666)
assert_eq!(scale_rect, 16.666_666)
}

#[test]
Expand Down
18 changes: 8 additions & 10 deletions src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,14 @@ mod tests {

#[test]
pub fn test_conditions() {
assert_eq!(V::ZERO.is_zero(), true);
assert_eq!(V::NORTH.is_zero(), false);

assert_eq!(V::ZERO.is_unit(), false);
assert_eq!(V::NORTH.is_unit(), true);
assert_eq!((V::NORTH.const_mul(2)).is_unit(), false);

assert_eq!(V::ZERO.is_diagonal(), false);
assert_eq!(V::NORTH.is_diagonal(), false);
assert_eq!(V::NORTH_EAST.is_diagonal(), true);
assert!(V::ZERO.is_zero());
assert!(!V::NORTH.is_zero());
assert!(!V::ZERO.is_unit());
assert!(V::NORTH.is_unit());
assert!(!(V::NORTH.const_mul(2)).is_unit());
assert!(!V::ZERO.is_diagonal());
assert!(!V::NORTH.is_diagonal());
assert!(V::NORTH_EAST.is_diagonal());
}

#[test]
Expand Down
3 changes: 2 additions & 1 deletion src/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ mod tests {

#[test]
fn test_get_tile() {
let vertex: Vertex<3, 3> = Vertex::new_const::<1, 1>();
use Corner::*;
let vertex: Vertex<3, 3> = Vertex::new_const::<1, 1>();

assert_eq!(vertex.get_tile(&NorthWest), Some(Tile::new_const::<0, 0>()));
assert_eq!(vertex.get_tile(&NorthEast), Some(Tile::new_const::<1, 0>()));
assert_eq!(vertex.get_tile(&SouthWest), Some(Tile::new_const::<0, 1>()));
Expand Down

0 comments on commit 94f8918

Please sign in to comment.