Fix clippy errors

This commit is contained in:
Yash Karandikar 2023-01-19 16:11:02 -06:00
parent 5aa2a67c17
commit 16a32372ee

View file

@ -1,3 +1,6 @@
#![warn(clippy::pedantic)]
#![allow(clippy::similar_names, clippy::too_many_lines, clippy::enum_glob_use)]
use cat_box::{draw_text, get_keyboard_state, Game, Sprite, SpriteCollection}; use cat_box::{draw_text, get_keyboard_state, Game, Sprite, SpriteCollection};
use rand::thread_rng; use rand::thread_rng;
use rand::Rng; use rand::Rng;
@ -172,18 +175,17 @@ fn main() {
} }
fn check_direction(square1: (i32, i32), square2: (i32, i32)) -> Direction { fn check_direction(square1: (i32, i32), square2: (i32, i32)) -> Direction {
if square1.0 < square2.0 { use std::cmp::Ordering::*;
return Direction::Left; use Direction::*;
} else if square1.0 > square2.0 { match square1.0.cmp(&square2.0) {
return Direction::Right; Less => Left,
}; Greater => Right,
if square1.1 > square2.1 { Equal => match square1.1.cmp(&square2.1) {
return Direction::Up; Less => Down,
} else if square1.1 < square2.1 { Greater => Up,
return Direction::Down; Equal => unreachable!(
}; "why are we still here? just to suffer? (this should never ever ever happen, by the way)"
),
unreachable!( },
"why are we still here? just to suffer? (this should never ever ever happen, by the way)" }
);
} }