Fix some clippy warnings
This commit is contained in:
16
src/grid.rs
16
src/grid.rs
@@ -10,11 +10,11 @@ pub const SEGMENT_SIZE: f32 = 20.;
|
||||
pub struct Coordinate(pub Index, pub Index);
|
||||
|
||||
impl Coordinate {
|
||||
pub fn splat(v: Index) -> Self {
|
||||
pub const fn splat(v: Index) -> Self {
|
||||
Self(v, v)
|
||||
}
|
||||
|
||||
pub fn in_bounds(self) -> bool {
|
||||
pub const fn in_bounds(self) -> bool {
|
||||
self.0 >= 0 && self.0 < SIZE && self.1 >= 0 && self.1 < SIZE
|
||||
}
|
||||
}
|
||||
@@ -22,14 +22,14 @@ impl Coordinate {
|
||||
impl Add for Coordinate {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Coordinate) -> Self::Output {
|
||||
Coordinate(self.0 + rhs.0, self.1 + rhs.1)
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
Self(self.0 + rhs.0, self.1 + rhs.1)
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for Coordinate {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
*self = Self(self.0 + rhs.0, self.1 + rhs.1)
|
||||
*self = Self(self.0 + rhs.0, self.1 + rhs.1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ impl From<Coordinate> for Vec2 {
|
||||
|
||||
impl From<&Coordinate> for Vec2 {
|
||||
fn from(grid_coordinate: &Coordinate) -> Self {
|
||||
Vec2::new(
|
||||
(grid_coordinate.0 - SIZE / 2) as f32 * SEGMENT_SIZE,
|
||||
(grid_coordinate.1 - SIZE / 2) as f32 * SEGMENT_SIZE,
|
||||
Self::new(
|
||||
f32::from(grid_coordinate.0 - SIZE / 2)* SEGMENT_SIZE,
|
||||
f32::from(grid_coordinate.1 - SIZE / 2) * SEGMENT_SIZE,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user