Skip to content

Commit

Permalink
chore: fix some clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
buxx committed Jul 17, 2023
1 parent 9a959ff commit 8d3e434
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
12 changes: 11 additions & 1 deletion battle_core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,21 @@ impl GridPath {
self.points.len()
}

pub fn is_empty(&self) -> bool {
self.points.len() == 0
}

pub fn push(&mut self, point: GridPoint) {
self.points.push(point)
}
}

impl Default for GridPath {
fn default() -> Self {
Self::new()
}
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct WorldPaths {
pub paths: Vec<WorldPath>,
Expand Down Expand Up @@ -321,7 +331,7 @@ impl WorldPaths {
}

pub fn remove_next_point(&mut self) -> Option<WorldPoint> {
while let Some(path) = self.paths.first_mut() {
if let Some(path) = self.paths.first_mut() {
let point = path
.remove_next_point()
.expect("We must use WorldPath.remove_next_point() only on feeded paths");
Expand Down
8 changes: 4 additions & 4 deletions battle_core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ impl WorldShape {
let center_offset = Vec2::new(width / 2., height / 2.);
let reference_point = self.top_left.apply(center_offset);

let after_top_left = apply_angle_on_point(&self.top_left, &reference_point, &angle);
let after_top_right = apply_angle_on_point(&self.top_right, &reference_point, &angle);
let after_bottom_right = apply_angle_on_point(&self.bottom_right, &reference_point, &angle);
let after_bottom_left = apply_angle_on_point(&self.bottom_left, &reference_point, &angle);
let after_top_left = apply_angle_on_point(&self.top_left, &reference_point, angle);
let after_top_right = apply_angle_on_point(&self.top_right, &reference_point, angle);
let after_bottom_right = apply_angle_on_point(&self.bottom_right, &reference_point, angle);
let after_bottom_left = apply_angle_on_point(&self.bottom_left, &reference_point, angle);

Self {
top_left: after_top_left,
Expand Down
7 changes: 3 additions & 4 deletions oc_core/src/resources.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fs, path::PathBuf};
use thiserror::Error;

pub const RESOURCE_PATH: &'static str = "./resources";
pub const RESOURCE_PATH: &str = "./resources";

pub struct Resources {
home: PathBuf,
Expand Down Expand Up @@ -83,9 +83,8 @@ where

impl EnsureDir for PathBuf {
fn ensure(self) -> Result<Self, ResourcesError> {
match fs::create_dir_all(&self) {
Err(error) => return Err(ResourcesError::MkDir(self.clone(), error.to_string())),
_ => {}
if let Err(error) = fs::create_dir_all(&self) {
return Err(ResourcesError::MkDir(self.clone(), error.to_string()));
}

Ok(self)
Expand Down
5 changes: 1 addition & 4 deletions oc_core/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ pub enum SpawnZoneName {
}
impl SpawnZoneName {
pub fn allowed_for_zone_object(&self) -> bool {
match self {
SpawnZoneName::All => false,
_ => true,
}
!matches!(self, SpawnZoneName::All)
}
}

Expand Down

0 comments on commit 8d3e434

Please sign in to comment.