Skip to content

Commit

Permalink
Merge pull request #688 from ozkriff/i687_fix_clippy_2023
Browse files Browse the repository at this point in the history
Fx clippy warnings
  • Loading branch information
ozkriff authored Jun 9, 2023
2 parents 455c8c8 + bf52cf5 commit fae7d89
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
3 changes: 0 additions & 3 deletions src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! This module groups all the async loading stuff.
// TODO: https://github.com/rust-lang/rust-clippy/issues/4637
#![allow(clippy::eval_order_dependence)]

use std::{collections::HashMap, hash::Hash};

use mq::{
Expand Down
21 changes: 7 additions & 14 deletions src/core/battle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,14 @@ pub struct Id(i32);
#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)]
pub struct Strength(pub i32);

#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, PartialOrd)]
#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)]
pub enum Weight {
#[default]
Normal = 0,

Heavy = 1,
Immovable = 2,
}

impl Default for Weight {
fn default() -> Self {
Weight::Normal
}
Immovable = 2,
}

impl fmt::Display for Weight {
Expand Down Expand Up @@ -132,14 +129,10 @@ pub struct Accuracy(pub i32);
#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)]
pub struct Dodge(pub i32);

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Eq)]
#[derive(Serialize, Deserialize, Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum TileType {
#[default]
Plain,
Rocks,
}

impl Default for TileType {
fn default() -> Self {
TileType::Plain
}
Rocks,
}
38 changes: 19 additions & 19 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@ use std::{error, fmt, io, path::PathBuf};

#[derive(Debug, derive_more::From)]
pub enum ZError {
UiError(ui::Error),
SceneError(zscene::Error),
RonDeserializeError {
Ui(ui::Error),
Scene(zscene::Error),
RonDeserialize {
error: ron::de::Error,
path: PathBuf,
},
IOError(io::Error),
MqFileError(mq::file::FileError),
MqFontError(mq::text::FontError),
IO(io::Error),
MqFile(mq::file::FileError),
MqFont(mq::text::FontError),
}

impl ZError {
pub fn from_ron_de_error(error: ron::de::Error, path: PathBuf) -> Self {
ZError::RonDeserializeError { error, path }
ZError::RonDeserialize { error, path }
}
}

impl fmt::Display for ZError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ZError::UiError(ref e) => write!(f, "ZGUI Error: {}", e),
ZError::SceneError(ref e) => write!(f, "ZScene Error: {}", e),
ZError::RonDeserializeError { error, path } => {
ZError::Ui(ref e) => write!(f, "ZGUI Error: {}", e),
ZError::Scene(ref e) => write!(f, "ZScene Error: {}", e),
ZError::RonDeserialize { error, path } => {
let s = path.to_str().unwrap_or("<no path>");
write!(f, "Can't deserialize '{}': {}", s, error)
}
ZError::IOError(ref e) => write!(f, "IO Error: {}", e),
ZError::MqFileError(ref e) => write!(f, "Macroquad File error: {}", e),
ZError::MqFontError(ref e) => write!(f, "Macroquad Font error: {}", e),
ZError::IO(ref e) => write!(f, "IO Error: {}", e),
ZError::MqFile(ref e) => write!(f, "Macroquad File error: {}", e),
ZError::MqFont(ref e) => write!(f, "Macroquad Font error: {}", e),
}
}
}

impl error::Error for ZError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
ZError::UiError(ref e) => Some(e),
ZError::SceneError(ref e) => Some(e),
ZError::RonDeserializeError { error, .. } => Some(error),
ZError::IOError(ref e) => Some(e),
ZError::MqFileError(ref e) => Some(e),
ZError::MqFontError(ref e) => Some(e),
ZError::Ui(ref e) => Some(e),
ZError::Scene(ref e) => Some(e),
ZError::RonDeserialize { error, .. } => Some(error),
ZError::IO(ref e) => Some(e),
ZError::MqFile(ref e) => Some(e),
ZError::MqFont(ref e) => Some(e),
}
}
}
7 changes: 5 additions & 2 deletions src/screen/main_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use log::trace;
use mq::math::Vec2;
use ui::{self, Gui, Widget};
use ui::{self, Widget};

use crate::{
assets,
Expand All @@ -16,8 +16,11 @@ use crate::{

#[derive(Copy, Clone, Debug)]
enum Message {
#[cfg_attr(target_arch = "wasm32", allow(unused))] // can't quit WASM so it's not used there
Exit,

StartInstant,

StartCampaign,
}

Expand Down Expand Up @@ -49,7 +52,7 @@ fn make_gui() -> ZResult<ui::Gui<Message>> {

#[derive(Debug)]
pub struct MainMenu {
gui: Gui<Message>,
gui: ui::Gui<Message>,
receiver_battle_result: Option<Receiver<Option<state::BattleResult>>>,
}

Expand Down
2 changes: 0 additions & 2 deletions zgui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ impl Drawable {
struct Sprite {
drawable: Drawable,
dimensions: Rect,
basic_scale: f32,
pos: Vec2,
scale: Vec2,
color: Color,
Expand All @@ -129,7 +128,6 @@ impl Sprite {
Self {
drawable,
dimensions,
basic_scale,
pos: Vec2::new(0.0, 0.0),
scale: Vec2::new(basic_scale, basic_scale),
color: SPRITE_COLOR,
Expand Down

0 comments on commit fae7d89

Please sign in to comment.