Update Rust toolchain.

This commit is contained in:
Joshua Yanovski 2022-09-08 12:51:02 -07:00
parent b4234523cb
commit 986d104faa
157 changed files with 604 additions and 612 deletions

12
Cargo.lock generated
View File

@ -5640,8 +5640,7 @@ dependencies = [
[[package]] [[package]]
name = "shaderc" name = "shaderc"
version = "0.8.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/pythonesque/shaderc-rs?rev=f2605a02062834019bedff911aee2fd2998c49f9#f2605a02062834019bedff911aee2fd2998c49f9"
checksum = "80e6fe602a861622769530a23bc40bfba31adbf186d0c8412e83f5519c5d6bee"
dependencies = [ dependencies = [
"libc", "libc",
"shaderc-sys", "shaderc-sys",
@ -5650,8 +5649,7 @@ dependencies = [
[[package]] [[package]]
name = "shaderc-sys" name = "shaderc-sys"
version = "0.8.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/pythonesque/shaderc-rs?rev=f2605a02062834019bedff911aee2fd2998c49f9#f2605a02062834019bedff911aee2fd2998c49f9"
checksum = "3794498651f8173d0afbc0bb8aca45ced111098227e755dde4c0ef2888c8d0bf"
dependencies = [ dependencies = [
"cmake", "cmake",
"libc", "libc",
@ -7806,7 +7804,7 @@ dependencies = [
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/gfx-rs/wgpu.git?rev=a92b8549a8e2cb9dac781bafc5ed32828f3caf46#a92b8549a8e2cb9dac781bafc5ed32828f3caf46" source = "git+https://github.com/pythonesque/wgpu.git?rev=179ea209374a92837cde252f1d9ee01f628cae08#179ea209374a92837cde252f1d9ee01f628cae08"
dependencies = [ dependencies = [
"arrayvec 0.5.2", "arrayvec 0.5.2",
"js-sys", "js-sys",
@ -7826,7 +7824,7 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-core" name = "wgpu-core"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/gfx-rs/wgpu.git?rev=a92b8549a8e2cb9dac781bafc5ed32828f3caf46#a92b8549a8e2cb9dac781bafc5ed32828f3caf46" source = "git+https://github.com/pythonesque/wgpu.git?rev=179ea209374a92837cde252f1d9ee01f628cae08#179ea209374a92837cde252f1d9ee01f628cae08"
dependencies = [ dependencies = [
"arrayvec 0.5.2", "arrayvec 0.5.2",
"bitflags", "bitflags",
@ -7866,7 +7864,7 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-types" name = "wgpu-types"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/gfx-rs/wgpu.git?rev=a92b8549a8e2cb9dac781bafc5ed32828f3caf46#a92b8549a8e2cb9dac781bafc5ed32828f3caf46" source = "git+https://github.com/pythonesque/wgpu.git?rev=179ea209374a92837cde252f1d9ee01f628cae08#179ea209374a92837cde252f1d9ee01f628cae08"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"serde", "serde",

View File

@ -122,7 +122,8 @@ nativeBuildInputs = ["pkg-config"]
[patch.crates-io] [patch.crates-io]
vek = { git = "https://github.com/yoanlcq/vek.git", rev = "84d5cb65841d46599a986c5477341bea4456be26" } vek = { git = "https://github.com/yoanlcq/vek.git", rev = "84d5cb65841d46599a986c5477341bea4456be26" }
# patch wgpu so we can use wgpu-profiler crate # patch wgpu so we can use wgpu-profiler crate
wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "a92b8549a8e2cb9dac781bafc5ed32828f3caf46" } # wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "a92b8549a8e2cb9dac781bafc5ed32828f3caf46" }
wgpu = { git = "https://github.com/pythonesque/wgpu.git", rev = "179ea209374a92837cde252f1d9ee01f628cae08" }
# # use the latest fixes in naga (remove when updates trickle down to wgpu-rs) # # use the latest fixes in naga (remove when updates trickle down to wgpu-rs)
# naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" } # naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" }

View File

@ -1,6 +1,6 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![feature(label_break_value, option_zip)] #![feature(option_zip)]
pub mod addr; pub mod addr;
pub mod error; pub mod error;
@ -318,7 +318,7 @@ impl Client {
server_info.git_hash, server_info.git_hash,
server_info.git_date, server_info.git_date,
common::util::GIT_HASH.to_string(), common::util::GIT_HASH.to_string(),
common::util::GIT_DATE.to_string(), *common::util::GIT_DATE,
); );
} }
// Pass the server info back to the caller to ensure they can access it even // Pass the server info back to the caller to ensure they can access it even
@ -2568,7 +2568,7 @@ impl Client {
pub fn players(&self) -> impl Iterator<Item = &str> { pub fn players(&self) -> impl Iterator<Item = &str> {
self.player_list() self.player_list()
.values() .values()
.filter_map(|player_info| player_info.is_online.then(|| &*player_info.player_alias)) .filter_map(|player_info| player_info.is_online.then_some(&*player_info.player_alias))
} }
/// Return true if this client is a moderator on the server /// Return true if this client is a moderator on the server

View File

@ -17,7 +17,7 @@ fn main() {
// Note: It will compare commits. As long as the commits do not diverge from the // Note: It will compare commits. As long as the commits do not diverge from the
// server no version change will be detected. // server no version change will be detected.
match Command::new("git") match Command::new("git")
.args(&[ .args([
"log", "log",
"-n", "-n",
"1", "1",
@ -40,7 +40,7 @@ fn main() {
// Note: It will compare commits. As long as the commits do not diverge from the // Note: It will compare commits. As long as the commits do not diverge from the
// server no version change will be detected. // server no version change will be detected.
match Command::new("git") match Command::new("git")
.args(&["describe", "--exact-match", "--tags", "HEAD"]) .args(["describe", "--exact-match", "--tags", "HEAD"])
.output() .output()
{ {
Ok(output) => match String::from_utf8(output.stdout) { Ok(output) => match String::from_utf8(output.stdout) {

View File

@ -5,7 +5,7 @@ use std::{collections::HashMap, time::Instant};
/// measuring the level of threads a unit of code ran on. Use Rayon when it ran /// measuring the level of threads a unit of code ran on. Use Rayon when it ran
/// on their threadpool. Use Exact when you know on how many threads your code /// on their threadpool. Use Exact when you know on how many threads your code
/// ran on exactly. /// ran on exactly.
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum ParMode { pub enum ParMode {
None, /* Job is not running at all */ None, /* Job is not running at all */
Single, Single,
@ -14,7 +14,7 @@ pub enum ParMode {
} }
//TODO: make use of the phase of a system for advanced scheduling and logging //TODO: make use of the phase of a system for advanced scheduling and logging
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Phase { pub enum Phase {
Create, Create,
Review, Review,
@ -22,7 +22,7 @@ pub enum Phase {
} }
//TODO: make use of the origin of the system for better logging //TODO: make use of the origin of the system for better logging
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub enum Origin { pub enum Origin {
Common, Common,
Client, Client,

View File

@ -28,7 +28,7 @@ pub enum ClientMsg {
2nd Level Enums 2nd Level Enums
*/ */
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ClientType { pub enum ClientType {
/// Regular Client like Voxygen who plays the game /// Regular Client like Voxygen who plays the game
Game, Game,
@ -39,7 +39,7 @@ pub enum ClientType {
Bot { privileged: bool }, Bot { privileged: bool },
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ClientRegister { pub struct ClientRegister {
pub token_or_username: String, pub token_or_username: String,
} }

View File

@ -36,7 +36,7 @@ impl<T: Serialize> CompressedData<T> {
let buf = Vec::with_capacity(uncompressed.len() / 10); let buf = Vec::with_capacity(uncompressed.len() / 10);
let mut encoder = DeflateEncoder::new(buf, Compression::new(level)); let mut encoder = DeflateEncoder::new(buf, Compression::new(level));
encoder.write_all(&*uncompressed).expect(EXPECT_MSG); encoder.write_all(&uncompressed).expect(EXPECT_MSG);
let compressed = encoder.finish().expect(EXPECT_MSG); let compressed = encoder.finish().expect(EXPECT_MSG);
CompressedData { CompressedData {
data: compressed, data: compressed,
@ -60,9 +60,9 @@ impl<T: for<'a> Deserialize<'a>> CompressedData<T> {
flate2::read::DeflateDecoder::new(&*self.data) flate2::read::DeflateDecoder::new(&*self.data)
.read_to_end(&mut uncompressed) .read_to_end(&mut uncompressed)
.ok()?; .ok()?;
bincode::deserialize(&*uncompressed).ok() bincode::deserialize(&uncompressed).ok()
} else { } else {
bincode::deserialize(&*self.data).ok() bincode::deserialize(&self.data).ok()
} }
} }
} }
@ -237,7 +237,7 @@ impl<const N: u32> VoxelImageEncoding for QuadPngEncoding<N> {
CompressionType::Rle, CompressionType::Rle,
FilterType::Up, FilterType::Up,
); );
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8) png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?; .ok()?;
indices[i] = buf.len(); indices[i] = buf.len();
Some(()) Some(())
@ -253,7 +253,7 @@ impl<const N: u32> VoxelImageEncoding for QuadPngEncoding<N> {
FilterType::Sub, FilterType::Sub,
); );
png.write_image( png.write_image(
&*ws.3.as_raw(), ws.3.as_raw(),
ws.3.width(), ws.3.width(),
ws.3.height(), ws.3.height(),
image::ColorType::Rgb8, image::ColorType::Rgb8,
@ -513,7 +513,7 @@ impl<const AVERAGE_PALETTE: bool> VoxelImageEncoding for TriPngEncoding<AVERAGE_
CompressionType::Rle, CompressionType::Rle,
FilterType::Up, FilterType::Up,
); );
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8) png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?; .ok()?;
indices[i] = buf.len(); indices[i] = buf.len();
Some(()) Some(())

View File

@ -22,7 +22,7 @@ pub use self::{
use common::character::CharacterId; use common::character::CharacterId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PresenceKind { pub enum PresenceKind {
Spectator, Spectator,
Character(CharacterId), Character(CharacterId),
@ -36,7 +36,7 @@ impl PresenceKind {
pub fn controlling_char(&self) -> bool { matches!(self, Self::Character(_) | Self::Possessor) } pub fn controlling_char(&self) -> bool { matches!(self, Self::Character(_) | Self::Possessor) }
} }
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PingMsg { pub enum PingMsg {
Ping, Ping,
Pong, Pong,

View File

@ -267,7 +267,7 @@ pub enum DisconnectReason {
Kicked(String), Kicked(String),
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum RegisterError { pub enum RegisterError {
AuthError(String), AuthError(String),
Banned(String), Banned(String),

View File

@ -8,7 +8,7 @@ pub enum CalendarEvent {
Christmas = 0, Christmas = 0,
} }
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Calendar { pub struct Calendar {
events: Vec<CalendarEvent>, events: Vec<CalendarEvent>,
} }

View File

@ -10,7 +10,7 @@ pub type CharacterId = i64;
pub const MAX_NAME_LENGTH: usize = 20; pub const MAX_NAME_LENGTH: usize = 20;
/// The minimum character data we need to create a new character on the server. /// The minimum character data we need to create a new character on the server.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Character { pub struct Character {
pub id: Option<CharacterId>, pub id: Option<CharacterId>,
pub alias: String, pub alias: String,

View File

@ -39,7 +39,7 @@ impl ChatCommandData {
} }
} }
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
pub enum KitSpec { pub enum KitSpec {
Item(String), Item(String),
ModularWeapon { ModularWeapon {
@ -47,7 +47,7 @@ pub enum KitSpec {
material: comp::item::Material, material: comp::item::Material,
}, },
} }
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
pub struct KitManifest(pub HashMap<String, Vec<(KitSpec, u32)>>); pub struct KitManifest(pub HashMap<String, Vec<(KitSpec, u32)>>);
impl assets::Asset for KitManifest { impl assets::Asset for KitManifest {
type Loader = assets::RonLoader; type Loader = assets::RonLoader;
@ -55,7 +55,7 @@ impl assets::Asset for KitManifest {
const EXTENSION: &'static str = "ron"; const EXTENSION: &'static str = "ron";
} }
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
pub struct SkillPresetManifest(pub HashMap<String, Vec<(Skill, u8)>>); pub struct SkillPresetManifest(pub HashMap<String, Vec<(Skill, u8)>>);
impl assets::Asset for SkillPresetManifest { impl assets::Asset for SkillPresetManifest {
type Loader = assets::RonLoader; type Loader = assets::RonLoader;
@ -875,7 +875,7 @@ impl FromStr for ServerChatCommand {
.filter_map(|c| c.short_keyword().map(|s| (s, c))) .filter_map(|c| c.short_keyword().map(|s| (s, c)))
.chain(Self::iter().map(|c| (c.keyword(), c))) .chain(Self::iter().map(|c| (c.keyword(), c)))
// Find command with matching string as keyword // Find command with matching string as keyword
.find_map(|(kwd, command)| (kwd == keyword).then(|| command)) .find_map(|(kwd, command)| (kwd == keyword).then_some(command))
// Return error if not found // Return error if not found
.ok_or(()) .ok_or(())
} }

View File

@ -901,7 +901,7 @@ pub struct Knockback {
} }
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum KnockbackDir { pub enum KnockbackDir {
Away, Away,
Towards, Towards,

View File

@ -326,7 +326,7 @@ impl From<MovementAbility> for Ability {
} }
} }
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)] #[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
pub enum AuxiliaryAbility { pub enum AuxiliaryAbility {
MainWeapon(usize), MainWeapon(usize),
OffWeapon(usize), OffWeapon(usize),

View File

@ -21,7 +21,7 @@ pub const TRADE_INTERACTION_TIME: f32 = 300.0;
const AWARENESS_DECREMENT_CONSTANT: f32 = 2.1; const AWARENESS_DECREMENT_CONSTANT: f32 = 2.1;
const SECONDS_BEFORE_FORGET_SOUNDS: f64 = 180.0; const SECONDS_BEFORE_FORGET_SOUNDS: f64 = 180.0;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Alignment { pub enum Alignment {
/// Wild animals and gentle giants /// Wild animals and gentle giants
Wild, Wild,
@ -37,7 +37,7 @@ pub enum Alignment {
Passive, Passive,
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Mark { pub enum Mark {
Merchant, Merchant,
Guard, Guard,

View File

@ -4,7 +4,7 @@ use vek::Vec2;
/// This component exists in order to fix a bug that caused entities /// This component exists in order to fix a bug that caused entities
/// such as campfires to duplicate because the chunk was double-loaded. /// such as campfires to duplicate because the chunk was double-loaded.
/// See https://gitlab.com/veloren/veloren/-/merge_requests/1543 /// See https://gitlab.com/veloren/veloren/-/merge_requests/1543
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Anchor { pub enum Anchor {
/// An entity with an Entity Anchor will be destroyed when its anchor Entity /// An entity with an Entity Anchor will be destroyed when its anchor Entity
/// no longer exists /// no longer exists

View File

@ -70,7 +70,7 @@ pub enum AuraTarget {
All, All,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum Specifier { pub enum Specifier {
WardingAura, WardingAura,
HealingAura, HealingAura,

View File

@ -34,7 +34,7 @@ impl std::ops::Deref for BeamSegment {
fn deref(&self) -> &Properties { &self.properties } fn deref(&self) -> &Properties { &self.properties }
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Beam { pub struct Beam {
pub hit_entities: Vec<Uid>, pub hit_entities: Vec<Uid>,
pub tick_dur: Duration, pub tick_dur: Duration,
@ -45,7 +45,7 @@ impl Component for Beam {
type Storage = specs::DenseVecStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum FrontendSpecifier { pub enum FrontendSpecifier {
Flamethrower, Flamethrower,
LifestealBeam, LifestealBeam,

View File

@ -10,13 +10,13 @@ pub struct Body {
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -15,13 +15,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -14,13 +14,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -29,13 +29,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { Self {
species, species,
body_type, body_type,

View File

@ -106,7 +106,7 @@ make_case_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
*(&ALL_OBJECTS).choose(&mut rng).unwrap() *ALL_OBJECTS.choose(&mut rng).unwrap()
} }
} }

View File

@ -15,13 +15,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -15,13 +15,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -15,13 +15,13 @@ make_proj_elim!(
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -42,13 +42,13 @@ impl Body {
Self::random_with(&mut rng) Self::random_with(&mut rng)
} }
pub fn random_with(rng: &mut impl rand::Rng) -> Self { *(&ALL_BODIES).choose(rng).unwrap() } pub fn random_with(rng: &mut impl rand::Rng) -> Self { *ALL_BODIES.choose(rng).unwrap() }
pub fn random_airship_with(rng: &mut impl rand::Rng) -> Self { pub fn random_airship_with(rng: &mut impl rand::Rng) -> Self {
*(&ALL_AIRSHIPS).choose(rng).unwrap() *ALL_AIRSHIPS.choose(rng).unwrap()
} }
pub fn random_ship_with(rng: &mut impl rand::Rng) -> Self { *(&ALL_SHIPS).choose(rng).unwrap() } pub fn random_ship_with(rng: &mut impl rand::Rng) -> Self { *ALL_SHIPS.choose(rng).unwrap() }
/// Return the structure manifest that this ship uses. `None` means that it /// Return the structure manifest that this ship uses. `None` means that it
/// should be derived from the collider. /// should be derived from the collider.

View File

@ -10,13 +10,13 @@ pub struct Body {
impl Body { impl Body {
pub fn random() -> Self { pub fn random() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); let species = *ALL_SPECIES.choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species) Self::random_with(&mut rng, &species)
} }
#[inline] #[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
Self { species, body_type } Self { species, body_type }
} }
} }

View File

@ -422,7 +422,7 @@ impl PartialEq for Buff {
} }
/// Source of the de/buff /// Source of the de/buff
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub enum BuffSource { pub enum BuffSource {
/// Applied by a character /// Applied by a character
Character { by: Uid }, Character { by: Uid },
@ -505,7 +505,7 @@ impl Buffs {
self.kinds self.kinds
.get(&kind) .get(&kind)
.map(|ids| ids.iter()) .map(|ids| ids.iter())
.unwrap_or_else(|| (&[]).iter()) .unwrap_or_else(|| [].iter())
.map(move |id| (*id, &self.buffs[id])) .map(move |id| (*id, &self.buffs[id]))
} }

View File

@ -17,7 +17,7 @@ use specs::Component;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use vek::*; use vek::*;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InventoryEvent { pub enum InventoryEvent {
Pickup(Uid), Pickup(Uid),
Swap(InvSlotId, InvSlotId), Swap(InvSlotId, InvSlotId),
@ -31,7 +31,7 @@ pub enum InventoryEvent {
}, },
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InventoryAction { pub enum InventoryAction {
Swap(EquipSlot, Slot), Swap(EquipSlot, Slot),
Drop(EquipSlot), Drop(EquipSlot),
@ -40,7 +40,7 @@ pub enum InventoryAction {
Collect(Vec3<i32>), Collect(Vec3<i32>),
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InventoryManip { pub enum InventoryManip {
Pickup(Uid), Pickup(Uid),
Collect(Vec3<i32>), Collect(Vec3<i32>),
@ -93,7 +93,7 @@ impl From<InventoryEvent> for InventoryManip {
} }
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum CraftEvent { pub enum CraftEvent {
Simple { Simple {
recipe: String, recipe: String,
@ -115,7 +115,7 @@ pub enum CraftEvent {
}, },
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum GroupManip { pub enum GroupManip {
Leave, Leave,
Kick(Uid), Kick(Uid),
@ -136,7 +136,7 @@ pub enum UtteranceKind {
* sounds */ * sounds */
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ControlEvent { pub enum ControlEvent {
//ToggleLantern, //ToggleLantern,
EnableLantern, EnableLantern,
@ -230,7 +230,7 @@ pub struct InputAttr {
pub target_entity: Option<Uid>, pub target_entity: Option<Uid>,
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Climb { pub enum Climb {
Up, Up,
Down, Down,

View File

@ -66,7 +66,7 @@ impl Energy {
// NaN does not need to be handled here as rust will automatically change to 0 when casting to u32 // NaN does not need to be handled here as rust will automatically change to 0 when casting to u32
.clamp(0.0, Self::MAX_SCALED_ENERGY as f32) as u32; .clamp(0.0, Self::MAX_SCALED_ENERGY as f32) as u32;
(maximum != self.maximum).then(|| maximum) (maximum != self.maximum).then_some(maximum)
} }
/// Updates the maximum value for energy. /// Updates the maximum value for energy.

View File

@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
use std::f32::consts::PI; use std::f32::consts::PI;
use vek::*; use vek::*;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum LiquidKind { pub enum LiquidKind {
Water, Water,
Lava, Lava,

View File

@ -38,7 +38,7 @@ pub struct GroupInfo {
pub name: String, pub name: String,
} }
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Role { pub enum Role {
Member, Member,
Pet, Pet,
@ -504,7 +504,7 @@ impl GroupManager {
self.groups[group.0 as usize].leader = new_leader; self.groups[group.0 as usize].leader = new_leader;
// Point to new leader // Point to new leader
members(group, &*groups, entities, alignments, uids).for_each(|(e, role)| match role { members(group, groups, entities, alignments, uids).for_each(|(e, role)| match role {
Role::Member => notifier(e, ChangeNotification::NewLeader(new_leader)), Role::Member => notifier(e, ChangeNotification::NewLeader(new_leader)),
Role::Pet => {}, Role::Pet => {},
}); });

View File

@ -105,7 +105,7 @@ impl Health {
// NaN does not need to be handled here as rust will automatically change to 0 when casting to u32 // NaN does not need to be handled here as rust will automatically change to 0 when casting to u32
.clamp(0.0, Self::MAX_SCALED_HEALTH as f32) as u32; .clamp(0.0, Self::MAX_SCALED_HEALTH as f32) as u32;
(maximum != self.maximum).then(|| maximum) (maximum != self.maximum).then_some(maximum)
} }
/// Updates the maximum value for health. /// Updates the maximum value for health.
@ -172,8 +172,8 @@ impl Health {
.damage_contributors .damage_contributors
.entry(attacker) .entry(attacker)
.or_insert((0, change.time)); .or_insert((0, change.time));
(*entry).0 += u64::try_from(-delta).unwrap_or(0); entry.0 += u64::try_from(-delta).unwrap_or(0);
(*entry).1 = change.time entry.1 = change.time
} }
// Prune any damage contributors who haven't contributed damage for over the // Prune any damage contributors who haven't contributed damage for over the

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use specs::{Component, DenseVecStorage, DerefFlaggedStorage}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage};
use vek::geom::Aabb; use vek::geom::Aabb;
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct CanBuild { pub struct CanBuild {
pub enabled: bool, pub enabled: bool,
pub build_areas: HashSet<Id<Aabb<i32>>>, pub build_areas: HashSet<Id<Aabb<i32>>>,

View File

@ -35,7 +35,7 @@ impl Armor {
} }
/// longitudinal and lateral friction, only meaningful for footwear /// longitudinal and lateral friction, only meaningful for footwear
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Friction { pub enum Friction {
Normal, Normal,
Ski, Ski,

View File

@ -210,7 +210,7 @@ impl TagExampleInfo for Material {
fn exemplar_identifier(&self) -> Option<&str> { self.asset_identifier() } fn exemplar_identifier(&self) -> Option<&str> { self.asset_identifier() }
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ItemTag { pub enum ItemTag {
/// Used to indicate that an item is composed of this material /// Used to indicate that an item is composed of this material
Material(Material), Material(Material),
@ -559,7 +559,7 @@ impl TryFrom<(&Item, &AbilityMap, &MaterialStatManifest)> for ItemConfig {
ability_map.get_ability_set(key) ability_map.get_ability_set(key)
}; };
let abilities = if let Some(set_key) = item.ability_spec() { let abilities = if let Some(set_key) = item.ability_spec() {
if let Some(set) = ability_map.get_ability_set(&*set_key) { if let Some(set) = ability_map.get_ability_set(&set_key) {
set.clone().modified_by_tool(tool) set.clone().modified_by_tool(tool)
} else { } else {
error!( error!(

View File

@ -239,7 +239,7 @@ pub enum ModularComponent {
}, },
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum WeaponName { pub enum WeaponName {
Universal(String), Universal(String),
HandednessDependent { HandednessDependent {

View File

@ -798,7 +798,7 @@ fn default_main_tool(body: &Body) -> Item {
#[derive(Clone)] #[derive(Clone)]
pub struct LoadoutBuilder(Loadout); pub struct LoadoutBuilder(Loadout);
#[derive(Copy, Clone, PartialEq, Deserialize, Serialize, Debug, EnumIter)] #[derive(Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Debug, EnumIter)]
pub enum Preset { pub enum Preset {
HuskSummon, HuskSummon,
} }
@ -1083,7 +1083,7 @@ impl LoadoutBuilder {
// Panic if item doesn't correspond to slot // Panic if item doesn't correspond to slot
assert!( assert!(
item.as_ref() item.as_ref()
.map_or(true, |item| equip_slot.can_hold(&*item.kind())) .map_or(true, |item| equip_slot.can_hold(&item.kind()))
); );
self.0.swap(equip_slot, item); self.0.swap(equip_slot, item);

View File

@ -559,7 +559,7 @@ impl Inventory {
#[must_use = "Returned items will be lost if not used"] #[must_use = "Returned items will be lost if not used"]
pub fn equip(&mut self, inv_slot: InvSlotId) -> Vec<Item> { pub fn equip(&mut self, inv_slot: InvSlotId) -> Vec<Item> {
self.get(inv_slot) self.get(inv_slot)
.and_then(|item| self.loadout.get_slot_to_equip_into(&*item.kind())) .and_then(|item| self.loadout.get_slot_to_equip_into(&item.kind()))
.map(|equip_slot| self.swap_inventory_loadout(inv_slot, equip_slot)) .map(|equip_slot| self.swap_inventory_loadout(inv_slot, equip_slot))
.unwrap_or_else(Vec::new) .unwrap_or_else(Vec::new)
} }
@ -570,7 +570,7 @@ impl Inventory {
pub fn free_after_equip(&self, inv_slot: InvSlotId) -> i32 { pub fn free_after_equip(&self, inv_slot: InvSlotId) -> i32 {
let (inv_slot_for_equipped, slots_from_equipped) = self let (inv_slot_for_equipped, slots_from_equipped) = self
.get(inv_slot) .get(inv_slot)
.and_then(|item| self.loadout.get_slot_to_equip_into(&*item.kind())) .and_then(|item| self.loadout.get_slot_to_equip_into(&item.kind()))
.and_then(|equip_slot| self.equipped(equip_slot)) .and_then(|equip_slot| self.equipped(equip_slot))
.map_or((1, 0), |item| (0, item.slots().len())); .map_or((1, 0), |item| (0, item.slots().len()));

View File

@ -6,12 +6,12 @@ use crate::comp::inventory::{
loadout::LoadoutSlotId, loadout::LoadoutSlotId,
}; };
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum SlotError { pub enum SlotError {
InventoryFull, InventoryFull,
} }
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub enum Slot { pub enum Slot {
Inventory(InvSlotId), Inventory(InvSlotId),
Equip(EquipSlot), Equip(EquipSlot),

View File

@ -459,7 +459,7 @@ impl EqualitySet {
let canonical_itemname = self let canonical_itemname = self
.equivalence_class .equivalence_class
.get(item_name) .get(item_name)
.map_or(item_name, |i| &*i); .map_or(item_name, |i| i);
canonical_itemname canonical_itemname
} }

View File

@ -1,13 +1,13 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InviteKind { pub enum InviteKind {
Group, Group,
Trade, Trade,
} }
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum InviteResponse { pub enum InviteResponse {
Accept, Accept,
Decline, Decline,

View File

@ -3,7 +3,7 @@ use crate::uid::Uid;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Object { pub enum Object {
Bomb { Bomb {
owner: Option<Uid>, owner: Option<Uid>,

View File

@ -156,14 +156,14 @@ impl Component for Collider {
type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Sticky; pub struct Sticky;
impl Component for Sticky { impl Component for Sticky {
type Storage = DerefFlaggedStorage<Self, NullStorage<Self>>; type Storage = DerefFlaggedStorage<Self, NullStorage<Self>>;
} }
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Immovable; pub struct Immovable;
impl Component for Immovable { impl Component for Immovable {
@ -213,7 +213,7 @@ impl Component for PhysicsState {
/// Used to forcefully update the position, velocity, and orientation of the /// Used to forcefully update the position, velocity, and orientation of the
/// client /// client
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct ForceUpdate { pub struct ForceUpdate {
flag: bool, flag: bool,
counter: u64, counter: u64,

View File

@ -35,7 +35,7 @@ impl std::ops::Deref for Shockwave {
fn deref(&self) -> &Properties { &self.properties } fn deref(&self) -> &Properties { &self.properties }
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct ShockwaveHitEntities { pub struct ShockwaveHitEntities {
pub hit_entities: Vec<Uid>, pub hit_entities: Vec<Uid>,
} }
@ -44,7 +44,7 @@ impl Component for ShockwaveHitEntities {
type Storage = specs::DenseVecStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum FrontendSpecifier { pub enum FrontendSpecifier {
Ground, Ground,
Fire, Fire,

View File

@ -232,7 +232,7 @@ impl SkillGroup {
/// Contains all of a player's skill groups and skills. Provides methods for /// Contains all of a player's skill groups and skills. Provides methods for
/// manipulating assigned skills and skill groups including unlocking skills, /// manipulating assigned skills and skill groups including unlocking skills,
/// refunding skills etc. /// refunding skills etc.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct SkillSet { pub struct SkillSet {
skill_groups: HashMap<SkillGroupKind, SkillGroup>, skill_groups: HashMap<SkillGroupKind, SkillGroup>,
skills: HashMap<Skill, u16>, skills: HashMap<Skill, u16>,
@ -567,7 +567,7 @@ pub enum SpRewardError {
Overflow, Overflow,
} }
#[derive(Debug, PartialEq, Clone, Copy, Deserialize, Serialize)] #[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize, Serialize)]
pub enum SkillsPersistenceError { pub enum SkillsPersistenceError {
HashMismatch, HashMismatch,
DeserializationFailure, DeserializationFailure,

View File

@ -12,14 +12,14 @@ use crate::{
use serde::Deserialize; use serde::Deserialize;
use vek::*; use vek::*;
#[derive(Debug, Deserialize, Clone, PartialEq)] #[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
pub enum NameKind { pub enum NameKind {
Name(String), Name(String),
Automatic, Automatic,
Uninit, Uninit,
} }
#[derive(Debug, Deserialize, Clone, PartialEq)] #[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
pub enum BodyBuilder { pub enum BodyBuilder {
RandomWith(String), RandomWith(String),
Exact(Body), Exact(Body),

View File

@ -5,9 +5,7 @@
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![feature( #![feature(
associated_type_defaults, associated_type_defaults,
bool_to_option,
fundamental, fundamental,
label_break_value,
option_zip, option_zip,
trait_alias, trait_alias,
type_alias_impl_trait, type_alias_impl_trait,

View File

@ -76,7 +76,7 @@ impl<T> Lottery<T> {
pub fn total(&self) -> f32 { self.total } pub fn total(&self) -> f32 { self.total }
} }
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum LootSpec<T: AsRef<str>> { pub enum LootSpec<T: AsRef<str>> {
/// Asset specifier /// Asset specifier
Item(T), Item(T),

View File

@ -7,7 +7,7 @@ use rand::seq::SliceRandom;
use serde::Deserialize; use serde::Deserialize;
use std::str::FromStr; use std::str::FromStr;
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq, Eq)]
pub enum NpcKind { pub enum NpcKind {
Humanoid, Humanoid,
Wolf, Wolf,

View File

@ -191,7 +191,7 @@ impl Recipe {
for (inv_slot_id, slot) in inv.slots_with_id() { for (inv_slot_id, slot) in inv.slots_with_id() {
if let Some(item) = slot if let Some(item) = slot
.as_ref() .as_ref()
.filter(|item| item.matches_recipe_input(&*input, amount)) .filter(|item| item.matches_recipe_input(input, amount))
{ {
*input_max.entry(inv_slot_id).or_insert(0) += item.amount(); *input_max.entry(inv_slot_id).or_insert(0) += item.amount();
} }
@ -241,7 +241,7 @@ fn inventory_contains_ingredients<'a, I: Iterator<Item = (&'a RecipeInput, u32)>
for (inv_slot_id, slot) in inv.slots_with_id() { for (inv_slot_id, slot) in inv.slots_with_id() {
if let Some(item) = slot if let Some(item) = slot
.as_ref() .as_ref()
.filter(|item| item.matches_recipe_input(&*input, amount)) .filter(|item| item.matches_recipe_input(input, amount))
{ {
let claim = slot_claims.entry(inv_slot_id).or_insert(0); let claim = slot_claims.entry(inv_slot_id).or_insert(0);
slots.push((i as u32, inv_slot_id)); slots.push((i as u32, inv_slot_id));

View File

@ -9,7 +9,7 @@ use tracing::warn;
/// `SkillSetBuilder` preset. Consider using loading from assets, when possible. /// `SkillSetBuilder` preset. Consider using loading from assets, when possible.
/// When you're adding new enum variant, /// When you're adding new enum variant,
/// handle it in [`with_preset`](SkillSetBuilder::with_preset) method /// handle it in [`with_preset`](SkillSetBuilder::with_preset) method
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum Preset { pub enum Preset {
Rank1, Rank1,
Rank2, Rank2,

View File

@ -181,7 +181,7 @@ impl CharacterBehavior for Data {
} }
/// Used to specify a particular effect for frontend purposes /// Used to specify a particular effect for frontend purposes
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum FrontendSpecifier { pub enum FrontendSpecifier {
GroundCleave, GroundCleave,
} }

View File

@ -10,13 +10,13 @@ use serde::{Deserialize, Serialize};
use std::time::Duration; use std::time::Duration;
/// Separated out to condense update portions of character state /// Separated out to condense update portions of character state
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct StaticData { pub struct StaticData {
/// Time required to draw weapon /// Time required to draw weapon
pub buildup_duration: Duration, pub buildup_duration: Duration,
} }
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Data { pub struct Data {
/// Struct containing data that does not change over the course of the /// Struct containing data that does not change over the course of the
/// character state /// character state

View File

@ -8,7 +8,7 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Default)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
pub struct Data { pub struct Data {
pub is_sneaking: bool, pub is_sneaking: bool,
// None means unknown // None means unknown

View File

@ -175,7 +175,7 @@ impl CharacterBehavior for Data {
} }
} }
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum MovementBehavior { pub enum MovementBehavior {
Stationary, Stationary,
ForwardGround, ForwardGround,
@ -183,7 +183,7 @@ pub enum MovementBehavior {
Walking, Walking,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum FrontendSpecifier { pub enum FrontendSpecifier {
CultistVortex, CultistVortex,
} }

View File

@ -14,7 +14,7 @@ use std::time::Duration;
use vek::Vec3; use vek::Vec3;
/// Separated out to condense update portions of character state /// Separated out to condense update portions of character state
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct StaticData { pub struct StaticData {
/// Buildup to sprite interaction /// Buildup to sprite interaction
pub buildup_duration: Duration, pub buildup_duration: Duration,
@ -32,7 +32,7 @@ pub struct StaticData {
pub was_sneak: bool, pub was_sneak: bool,
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Data { pub struct Data {
/// Struct containing data that does not change over the course of the /// Struct containing data that does not change over the course of the
/// character state /// character state
@ -128,7 +128,7 @@ impl CharacterBehavior for Data {
} }
/// Used to control effects based off of the type of sprite interacted with /// Used to control effects based off of the type of sprite interacted with
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum SpriteInteractKind { pub enum SpriteInteractKind {
Chest, Chest,
Harvestable, Harvestable,

View File

@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
use std::time::Duration; use std::time::Duration;
/// Separated out to condense update portions of character state /// Separated out to condense update portions of character state
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct StaticData { pub struct StaticData {
/// Buildup to item use /// Buildup to item use
pub buildup_duration: Duration, pub buildup_duration: Duration,
@ -39,7 +39,7 @@ pub struct StaticData {
pub was_sneak: bool, pub was_sneak: bool,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Data { pub struct Data {
/// Struct containing data that does not change over the course of the /// Struct containing data that does not change over the course of the
/// character state /// character state
@ -163,7 +163,7 @@ impl CharacterBehavior for Data {
} }
/// Used to control effects based off of the type of item used /// Used to control effects based off of the type of item used
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ItemUseKind { pub enum ItemUseKind {
Consumable(ConsumableKind), Consumable(ConsumableKind),
} }

View File

@ -1199,7 +1199,7 @@ pub enum ForcedMovement {
}, },
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum MovementDirection { pub enum MovementDirection {
Look, Look,
Move, Move,
@ -1253,7 +1253,7 @@ impl AbilityInfo {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum HandInfo { pub enum HandInfo {
TwoHanded, TwoHanded,
MainHand, MainHand,

View File

@ -12,7 +12,7 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Data { pub struct Data {
pub is_sneaking: bool, pub is_sneaking: bool,
} }

View File

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SiteKindMeta { pub enum SiteKindMeta {
Dungeon(DungeonKindMeta), Dungeon(DungeonKindMeta),
Cave, Cave,
@ -9,13 +9,13 @@ pub enum SiteKindMeta {
Void, Void,
} }
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum DungeonKindMeta { pub enum DungeonKindMeta {
Old, Old,
Gnarling, Gnarling,
} }
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SettlementKindMeta { pub enum SettlementKindMeta {
Default, Default,
Cliff, Cliff,

View File

@ -12,7 +12,7 @@ use vek::*;
make_case_elim!( make_case_elim!(
structure_block, structure_block,
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)] #[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize)]
#[repr(u8)] #[repr(u8)]
pub enum StructureBlock { pub enum StructureBlock {
None = 0, None = 0,

View File

@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
use strum::EnumIter; use strum::EnumIter;
use tracing::{trace, warn}; use tracing::{trace, warn};
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum TradePhase { pub enum TradePhase {
Mutate, Mutate,
Review, Review,
@ -22,7 +22,7 @@ pub enum TradePhase {
/// Clients submit `TradeAction` to the server, which adds the Uid of the /// Clients submit `TradeAction` to the server, which adds the Uid of the
/// player out-of-band (i.e. without trusting the client to say who it's /// player out-of-band (i.e. without trusting the client to say who it's
/// accepting on behalf of) /// accepting on behalf of)
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum TradeAction { pub enum TradeAction {
AddItem { AddItem {
item: InvSlotId, item: InvSlotId,
@ -41,7 +41,7 @@ pub enum TradeAction {
Decline, Decline,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum TradeResult { pub enum TradeResult {
Completed, Completed,
Declined, Declined,
@ -73,7 +73,7 @@ pub enum TradeResult {
/// trading currently-equipped items (since `EquipSlot`s are disjoint from /// trading currently-equipped items (since `EquipSlot`s are disjoint from
/// `InvSlotId`s), which avoids the issues associated with trading equipped bags /// `InvSlotId`s), which avoids the issues associated with trading equipped bags
/// that may still have contents. /// that may still have contents.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct PendingTrade { pub struct PendingTrade {
/// `parties[0]` is the entity that initiated the trade, parties[1] is the /// `parties[0]` is the entity that initiated the trade, parties[1] is the
/// other entity that's being traded with /// other entity that's being traded with
@ -239,7 +239,7 @@ impl Trades {
None => return, None => return,
} }
} }
trade.process_trade_action(party, action, &*inventories); trade.process_trade_action(party, action, &inventories);
} else { } else {
warn!( warn!(
"An entity who is not a party to trade {:?} tried to modify it", "An entity who is not a party to trade {:?} tried to modify it",

View File

@ -13,7 +13,7 @@ pub enum PluginError {
#[derive(Debug)] #[derive(Debug)]
pub enum PluginModuleError { pub enum PluginModuleError {
InstantiationError(InstantiationError), InstantiationError(Box<InstantiationError>),
MemoryAllocation(MemoryAllocationError), MemoryAllocation(MemoryAllocationError),
MemoryUninit(ExportError), MemoryUninit(ExportError),
FindFunction(ExportError), FindFunction(ExportError),

View File

@ -114,7 +114,7 @@ pub struct PluginMgr {
impl PluginMgr { impl PluginMgr {
pub fn from_assets() -> Result<Self, PluginError> { pub fn from_assets() -> Result<Self, PluginError> {
let mut assets_path = (&*ASSETS_PATH).clone(); let mut assets_path = (*ASSETS_PATH).clone();
assets_path.push("plugins"); assets_path.push("plugins");
info!("Searching {:?} for plugins...", assets_path); info!("Searching {:?} for plugins...", assets_path);
Self::from_dir(assets_path) Self::from_dir(assets_path)

View File

@ -37,7 +37,7 @@ impl PluginModule {
// We are creating an enironnement // We are creating an enironnement
let store = Store::new(&engine); let store = Store::new(&engine);
// We are compiling the WASM file in the previously generated environement // We are compiling the WASM file in the previously generated environement
let module = Module::new(&store, &wasm_data).expect("Can't compile"); let module = Module::new(&store, wasm_data).expect("Can't compile");
// This is the function imported into the wasm environement // This is the function imported into the wasm environement
fn raw_emit_actions(env: &HostFunctionEnvironement, ptr: i64, len: i64) { fn raw_emit_actions(env: &HostFunctionEnvironement, ptr: i64, len: i64) {
@ -79,7 +79,7 @@ impl PluginModule {
// Create an instance (Code execution environement) // Create an instance (Code execution environement)
let instance = Instance::new(&module, &import_object) let instance = Instance::new(&module, &import_object)
.map_err(PluginModuleError::InstantiationError)?; .map_err(|err| PluginModuleError::InstantiationError(Box::new(err)))?;
Ok(Self { Ok(Self {
memory_manager, memory_manager,
ecs, ecs,

View File

@ -212,7 +212,7 @@ impl<'a> System<'a> for Sys {
for (kind, ids) in buff_comp_kinds.iter() { for (kind, ids) in buff_comp_kinds.iter() {
if kind.queues() { if kind.queues() {
if let Some((Some(buff), id)) = if let Some((Some(buff), id)) =
ids.get(0).map(|id| (buff_comp_buffs.get_mut(id), id)) ids.first().map(|id| (buff_comp_buffs.get_mut(id), id))
{ {
tick_buff(*id, buff, dt, |id| expired_buffs.push(id)); tick_buff(*id, buff, dt, |id| expired_buffs.push(id));
} }
@ -262,7 +262,7 @@ impl<'a> System<'a> for Sys {
buff.kind, buff.kind,
buff.time, buff.time,
&read_data, &read_data,
&mut *stat, &mut stat,
health, health,
energy, energy,
entity, entity,

View File

@ -1,4 +1,4 @@
#![feature(bool_to_option, let_else, btree_drain_filter)] #![feature(let_else, btree_drain_filter)]
#![allow(clippy::option_map_unit_fn)] #![allow(clippy::option_map_unit_fn)]
mod aura; mod aura;

View File

@ -540,7 +540,7 @@ impl<'a> PhysicsData<'a> {
.join() .join()
{ {
let vol = match collider { let vol = match collider {
Collider::Voxel { id } => voxel_colliders_manifest.colliders.get(&*id), Collider::Voxel { id } => voxel_colliders_manifest.colliders.get(id),
Collider::Volume(vol) => Some(&**vol), Collider::Volume(vol) => Some(&**vol),
_ => None, _ => None,
}; };

View File

@ -23,7 +23,7 @@ fn main() {
.short('m') .short('m')
.long("mode") .long("mode")
.takes_value(true) .takes_value(true)
.possible_values(&["server", "client", "both"]) .possible_values(["server", "client", "both"])
.default_value("both") .default_value("both")
.help( .help(
"choose whether you want to start the server or client or both needed for \ "choose whether you want to start the server or client or both needed for \
@ -50,7 +50,7 @@ fn main() {
.long("protocol") .long("protocol")
.takes_value(true) .takes_value(true)
.default_value("tcp") .default_value("tcp")
.possible_values(&["tcp", "upd", "mpsc"]) .possible_values(["tcp", "upd", "mpsc"])
.help( .help(
"underlying protocol used for this test, mpsc can only combined with mode=both", "underlying protocol used for this test, mpsc can only combined with mode=both",
), ),
@ -61,7 +61,7 @@ fn main() {
.long("trace") .long("trace")
.takes_value(true) .takes_value(true)
.default_value("warn") .default_value("warn")
.possible_values(&["trace", "debug", "info", "warn", "error"]) .possible_values(["trace", "debug", "info", "warn", "error"])
.help("set trace level, not this has a performance impact!"), .help("set trace level, not this has a performance impact!"),
) )
.get_matches(); .get_matches();

View File

@ -22,7 +22,7 @@ pub enum Command {
Get(u32), Get(u32),
} }
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct FileInfo { pub struct FileInfo {
id: u32, id: u32,
pub path: String, pub path: String,

View File

@ -34,7 +34,7 @@ fn main() {
.long("trace") .long("trace")
.takes_value(true) .takes_value(true)
.default_value("warn") .default_value("warn")
.possible_values(&["trace", "debug", "info", "warn", "error"]) .possible_values(["trace", "debug", "info", "warn", "error"])
.help("set trace level, not this has a performance impact!"), .help("set trace level, not this has a performance impact!"),
) )
.get_matches(); .get_matches();

View File

@ -36,7 +36,7 @@ fn main() {
.short('m') .short('m')
.long("mode") .long("mode")
.takes_value(true) .takes_value(true)
.possible_values(&["server", "client", "both"]) .possible_values(["server", "client", "both"])
.default_value("both") .default_value("both")
.help( .help(
"choose whether you want to start the server or client or both needed for \ "choose whether you want to start the server or client or both needed for \
@ -63,7 +63,7 @@ fn main() {
.long("protocol") .long("protocol")
.takes_value(true) .takes_value(true)
.default_value("tcp") .default_value("tcp")
.possible_values(&["tcp", "udp", "mpsc"]) .possible_values(["tcp", "udp", "mpsc"])
.help( .help(
"underlying protocol used for this test, mpsc can only combined with mode=both", "underlying protocol used for this test, mpsc can only combined with mode=both",
), ),
@ -74,7 +74,7 @@ fn main() {
.long("trace") .long("trace")
.takes_value(true) .takes_value(true)
.default_value("warn") .default_value("warn")
.possible_values(&["trace", "debug", "info", "warn", "error"]) .possible_values(["trace", "debug", "info", "warn", "error"])
.help("set trace level, not this has a performance impact!"), .help("set trace level, not this has a performance impact!"),
) )
.get_matches(); .get_matches();

View File

@ -1,7 +1,7 @@
/// All possible Errors that can happen during Handshake [`InitProtocol`] /// All possible Errors that can happen during Handshake [`InitProtocol`]
/// ///
/// [`InitProtocol`]: crate::InitProtocol /// [`InitProtocol`]: crate::InitProtocol
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum InitProtocolError<E: std::fmt::Debug + Send> { pub enum InitProtocolError<E: std::fmt::Debug + Send> {
Custom(E), Custom(E),
/// expected Handshake, didn't get handshake /// expected Handshake, didn't get handshake
@ -13,7 +13,7 @@ pub enum InitProtocolError<E: std::fmt::Debug + Send> {
} }
/// When you return closed you must stay closed! /// When you return closed you must stay closed!
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum ProtocolError<E: std::fmt::Debug + Send> { pub enum ProtocolError<E: std::fmt::Debug + Send> {
/// Custom Error on the underlying I/O, /// Custom Error on the underlying I/O,
/// e.g. the TCP, UDP or MPSC connection is dropped by the OS /// e.g. the TCP, UDP or MPSC connection is dropped by the OS

View File

@ -9,7 +9,7 @@ use bytes::Bytes;
/// [`SendProtocol`]: crate::SendProtocol /// [`SendProtocol`]: crate::SendProtocol
/// [`RecvProtocol`]: crate::RecvProtocol /// [`RecvProtocol`]: crate::RecvProtocol
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[cfg_attr(test, derive(PartialEq))] #[cfg_attr(test, derive(PartialEq, Eq))]
pub enum ProtocolEvent { pub enum ProtocolEvent {
Shutdown, Shutdown,
OpenStream { OpenStream {

View File

@ -14,7 +14,7 @@ const FRAME_RAW: u8 = 8;
//const FRAME_RESERVED_3: u8 = 13; //const FRAME_RESERVED_3: u8 = 13;
/// Used for Communication between Channel <----(TCP/UDP)----> Channel /// Used for Communication between Channel <----(TCP/UDP)----> Channel
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum InitFrame { pub enum InitFrame {
Handshake { Handshake {
magic_number: [u8; 7], magic_number: [u8; 7],
@ -30,7 +30,7 @@ pub enum InitFrame {
} }
/// Used for OUT TCP Communication between Channel --(TCP)--> Channel /// Used for OUT TCP Communication between Channel --(TCP)--> Channel
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum OTFrame { pub enum OTFrame {
Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully), Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully),
* Participant is deleted */ * Participant is deleted */
@ -55,7 +55,7 @@ pub enum OTFrame {
} }
/// Used for IN TCP Communication between Channel <--(TCP)-- Channel /// Used for IN TCP Communication between Channel <--(TCP)-- Channel
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum ITFrame { pub enum ITFrame {
Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully), Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully),
* Participant is deleted */ * Participant is deleted */
@ -113,7 +113,7 @@ impl InitFrame {
} }
pub(crate) fn read_frame(bytes: &mut BytesMut) -> Option<Self> { pub(crate) fn read_frame(bytes: &mut BytesMut) -> Option<Self> {
let frame_no = match bytes.get(0) { let frame_no = match bytes.first() {
Some(&f) => f, Some(&f) => f,
None => return None, None => return None,
}; };
@ -454,7 +454,7 @@ mod tests {
magic_number: VELOREN_MAGIC_NUMBER, magic_number: VELOREN_MAGIC_NUMBER,
version: VELOREN_NETWORK_VERSION, version: VELOREN_NETWORK_VERSION,
}; };
let _ = InitFrame::write_bytes(frame1, &mut buffer); InitFrame::write_bytes(frame1, &mut buffer);
buffer.truncate(6); // simulate partial retrieve buffer.truncate(6); // simulate partial retrieve
let frame1d = InitFrame::read_frame(&mut buffer); let frame1d = InitFrame::read_frame(&mut buffer);
assert_eq!(frame1d, None); assert_eq!(frame1d, None);
@ -474,7 +474,7 @@ mod tests {
let mut buffer = BytesMut::with_capacity(50); let mut buffer = BytesMut::with_capacity(50);
let frame1 = InitFrame::Raw(b"foobar".to_vec()); let frame1 = InitFrame::Raw(b"foobar".to_vec());
let _ = InitFrame::write_bytes(frame1.clone(), &mut buffer); InitFrame::write_bytes(frame1.clone(), &mut buffer);
buffer[1] = 255; buffer[1] = 255;
let framed = InitFrame::read_frame(&mut buffer); let framed = InitFrame::read_frame(&mut buffer);
assert_eq!(framed, Some(frame1)); assert_eq!(framed, Some(frame1));
@ -485,7 +485,7 @@ mod tests {
let mut buffer = BytesMut::with_capacity(50); let mut buffer = BytesMut::with_capacity(50);
let frame1 = InitFrame::Raw(b"foobar".to_vec()); let frame1 = InitFrame::Raw(b"foobar".to_vec());
let _ = InitFrame::write_bytes(frame1, &mut buffer); InitFrame::write_bytes(frame1, &mut buffer);
buffer[1] = 3; buffer[1] = 3;
let framed = InitFrame::read_frame(&mut buffer); let framed = InitFrame::read_frame(&mut buffer);
// we accept a different frame here, as it's RAW and debug only! // we accept a different frame here, as it's RAW and debug only!

View File

@ -18,7 +18,7 @@ use tracing::info;
#[cfg(feature = "trace_pedantic")] #[cfg(feature = "trace_pedantic")]
use tracing::trace; use tracing::trace;
#[derive(PartialEq)] #[derive(PartialEq, Eq)]
pub enum QuicDataFormatStream { pub enum QuicDataFormatStream {
Main, Main,
Reliable(Sid), Reliable(Sid),

View File

@ -121,7 +121,7 @@ pub enum NetworkConnectError {
} }
/// Error type thrown by [`Participants`](Participant) methods /// Error type thrown by [`Participants`](Participant) methods
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum ParticipantError { pub enum ParticipantError {
///Participant was closed by remote side ///Participant was closed by remote side
ParticipantDisconnected, ParticipantDisconnected,

View File

@ -1 +1 @@
nightly-2022-04-25 nightly-2022-09-08

View File

@ -1,6 +1,5 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![feature(bool_to_option)]
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
#[global_allocator] #[global_allocator]

View File

@ -13,7 +13,7 @@ use vek::Vec2;
/// Deferring allows us to remove code duplication and maybe serialize ONCE, /// Deferring allows us to remove code duplication and maybe serialize ONCE,
/// send to MULTIPLE clients /// send to MULTIPLE clients
/// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds /// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct ChunkSendEntry { pub struct ChunkSendEntry {
pub(crate) entity: Entity, pub(crate) entity: Entity,
pub(crate) chunk_key: Vec2<i32>, pub(crate) chunk_key: Vec2<i32>,

View File

@ -517,7 +517,7 @@ fn handle_give_item(
) -> CmdResult<()> { ) -> CmdResult<()> {
if let (Some(item_name), give_amount_opt) = parse_cmd_args!(args, String, u32) { if let (Some(item_name), give_amount_opt) = parse_cmd_args!(args, String, u32) {
let give_amount = give_amount_opt.unwrap_or(1); let give_amount = give_amount_opt.unwrap_or(1);
if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace('\\', ".")) { if let Ok(item) = Item::new_from_asset(&item_name.replace(['/', '\\'], ".")) {
let mut item: Item = item; let mut item: Item = item;
let mut res = Ok(()); let mut res = Ok(());
@ -1844,7 +1844,7 @@ fn handle_kill_npcs(
true true
}; };
should_kill.then(|| entity) should_kill.then_some(entity)
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
}; };

View File

@ -278,7 +278,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
let entry = damage_contributors let entry = damage_contributors
.entry(DamageContrib::Group(*group)) .entry(DamageContrib::Group(*group))
.or_insert((0, 0.0)); .or_insert((0, 0.0));
(*entry).0 += damage; entry.0 += damage;
}, },
} }
} }

View File

@ -2,10 +2,8 @@
#![allow(clippy::option_map_unit_fn)] #![allow(clippy::option_map_unit_fn)]
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![feature( #![feature(
bool_to_option,
box_patterns, box_patterns,
drain_filter, drain_filter,
label_break_value,
let_chains, let_chains,
let_else, let_else,
never_type, never_type,
@ -490,7 +488,7 @@ impl Server {
use std::fs; use std::fs;
match || -> Result<_, Box<dyn std::error::Error>> { match || -> Result<_, Box<dyn std::error::Error>> {
let key = fs::read(&key_file_path)?; let key = fs::read(key_file_path)?;
let key = if key_file_path.extension().map_or(false, |x| x == "der") { let key = if key_file_path.extension().map_or(false, |x| x == "der") {
rustls::PrivateKey(key) rustls::PrivateKey(key)
} else { } else {
@ -506,7 +504,7 @@ impl Server {
.ok_or("No valid pem key in file")?; .ok_or("No valid pem key in file")?;
rustls::PrivateKey(key) rustls::PrivateKey(key)
}; };
let cert_chain = fs::read(&cert_file_path)?; let cert_chain = fs::read(cert_file_path)?;
let cert_chain = if cert_file_path.extension().map_or(false, |x| x == "der") let cert_chain = if cert_file_path.extension().map_or(false, |x| x == "der")
{ {
vec![rustls::Certificate(cert_chain)] vec![rustls::Certificate(cert_chain)]
@ -585,7 +583,7 @@ impl Server {
let editable_settings = self.state.ecs().fetch::<EditableSettings>(); let editable_settings = self.state.ecs().fetch::<EditableSettings>();
ServerInfo { ServerInfo {
name: settings.server_name.clone(), name: settings.server_name.clone(),
description: (&*editable_settings.server_description).clone(), description: (*editable_settings.server_description).clone(),
git_hash: common::util::GIT_HASH.to_string(), git_hash: common::util::GIT_HASH.to_string(),
git_date: common::util::GIT_DATE.to_string(), git_date: common::util::GIT_DATE.to_string(),
auth_provider: settings.auth_server_address.clone(), auth_provider: settings.auth_server_address.clone(),

View File

@ -86,7 +86,7 @@ impl CharacterLoader {
// This connection -must- remain read-only to avoid lock contention with the // This connection -must- remain read-only to avoid lock contention with the
// CharacterUpdater thread. // CharacterUpdater thread.
let mut conn = let mut conn =
establish_connection(&*settings.read().unwrap(), ConnectionMode::ReadOnly); establish_connection(&settings.read().unwrap(), ConnectionMode::ReadOnly);
for request in internal_rx { for request in internal_rx {
conn.update_log_mode(&settings); conn.update_log_mode(&settings);

View File

@ -83,7 +83,7 @@ impl CharacterUpdater {
// Unwrap here is safe as there is no code that can panic when the write lock is // Unwrap here is safe as there is no code that can panic when the write lock is
// taken that could cause the RwLock to become poisoned. // taken that could cause the RwLock to become poisoned.
let mut conn = let mut conn =
establish_connection(&*settings.read().unwrap(), ConnectionMode::ReadWrite); establish_connection(&settings.read().unwrap(), ConnectionMode::ReadWrite);
while let Ok(updates) = update_rx.recv() { while let Ok(updates) = update_rx.recv() {
match updates { match updates {
CharacterUpdaterEvent::BatchUpdate(updates) => { CharacterUpdaterEvent::BatchUpdate(updates) => {

View File

@ -63,12 +63,12 @@ impl VelorenConnection {
let settings = database_settings let settings = database_settings
.read() .read()
.expect("DatabaseSettings RwLock was poisoned"); .expect("DatabaseSettings RwLock was poisoned");
if self.sql_log_mode == (*settings).sql_log_mode { if self.sql_log_mode == settings.sql_log_mode {
return; return;
} }
set_log_mode(&mut self.connection, (*settings).sql_log_mode); set_log_mode(&mut self.connection, settings.sql_log_mode);
self.sql_log_mode = (*settings).sql_log_mode; self.sql_log_mode = settings.sql_log_mode;
info!( info!(
"SQL log mode for connection changed to {:?}", "SQL log mode for connection changed to {:?}",
@ -106,13 +106,13 @@ pub struct DatabaseSettings {
pub sql_log_mode: SqlLogMode, pub sql_log_mode: SqlLogMode,
} }
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq, Eq)]
pub enum ConnectionMode { pub enum ConnectionMode {
ReadOnly, ReadOnly,
ReadWrite, ReadWrite,
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SqlLogMode { pub enum SqlLogMode {
/// Logging is disabled /// Logging is disabled
Disabled, Disabled,
@ -199,10 +199,8 @@ pub(crate) fn establish_connection(
settings: &DatabaseSettings, settings: &DatabaseSettings,
connection_mode: ConnectionMode, connection_mode: ConnectionMode,
) -> VelorenConnection { ) -> VelorenConnection {
fs::create_dir_all(&settings.db_dir).expect(&*format!( fs::create_dir_all(&settings.db_dir)
"Failed to create saves directory: {:?}", .unwrap_or_else(|_| panic!("Failed to create saves directory: {:?}", &settings.db_dir));
&settings.db_dir
));
let open_flags = OpenFlags::SQLITE_OPEN_PRIVATE_CACHE let open_flags = OpenFlags::SQLITE_OPEN_PRIVATE_CACHE
| OpenFlags::SQLITE_OPEN_NO_MUTEX | OpenFlags::SQLITE_OPEN_NO_MUTEX

View File

@ -88,7 +88,7 @@ impl Entity {
.into() .into()
}, },
_ => { _ => {
let species = *(&comp::humanoid::ALL_SPECIES) let species = *comp::humanoid::ALL_SPECIES
.choose(&mut self.rng(PERM_SPECIES)) .choose(&mut self.rng(PERM_SPECIES))
.unwrap(); .unwrap();
comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into() comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into()
@ -102,7 +102,7 @@ impl Entity {
| RtSimEntityKind::Alchemist | RtSimEntityKind::Alchemist
| RtSimEntityKind::Blacksmith | RtSimEntityKind::Blacksmith
| RtSimEntityKind::Merchant => { | RtSimEntityKind::Merchant => {
let species = *(&comp::humanoid::ALL_SPECIES) let species = *comp::humanoid::ALL_SPECIES
.choose(&mut self.rng(PERM_SPECIES)) .choose(&mut self.rng(PERM_SPECIES))
.unwrap(); .unwrap();
comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into() comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into()

View File

@ -703,8 +703,10 @@ impl StateExt for State {
msg: &str, msg: &str,
) -> bool { ) -> bool {
let mut automod = self.ecs().write_resource::<AutoMod>(); let mut automod = self.ecs().write_resource::<AutoMod>();
let Some(client) = self.ecs().read_storage::<Client>().get(entity) else { return true }; let client = self.ecs().read_storage::<Client>();
let Some(player) = self.ecs().read_storage::<Player>().get(entity) else { return true }; let player = self.ecs().read_storage::<Player>();
let Some(client) = client.get(entity) else { return true };
let Some(player) = player.get(entity) else { return true };
match automod.validate_chat_msg( match automod.validate_chat_msg(
player.uuid(), player.uuid(),

View File

@ -557,7 +557,7 @@ impl<'a> AgentData<'a> {
tgt_pos: &Pos, tgt_pos: &Pos,
) { ) {
if let Some((bearing, speed)) = agent.chaser.chase( if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain, terrain,
self.pos.0, self.pos.0,
self.vel.0, self.vel.0,
tgt_pos.0, tgt_pos.0,
@ -666,7 +666,7 @@ impl<'a> AgentData<'a> {
} }
if let Some((bearing, speed)) = agent.chaser.chase( if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain, terrain,
self.pos.0, self.pos.0,
self.vel.0, self.vel.0,
// Away from the target (ironically) // Away from the target (ironically)

View File

@ -393,7 +393,7 @@ impl<'a> System<'a> for Sys {
let outcomes = outcomes let outcomes = outcomes
.iter() .iter()
.filter(|o| o.get_pos().and_then(&is_near).unwrap_or(true)) .filter(|o| o.get_pos().and_then(is_near).unwrap_or(true))
.cloned() .cloned()
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View File

@ -136,9 +136,9 @@ impl<'a> System<'a> for Sys {
&ecs_world, &ecs_world,
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
&read_data._plugin_mgr, &read_data._plugin_mgr,
&*read_data.editable_settings.admins, &read_data.editable_settings.admins,
&*read_data.editable_settings.whitelist, &read_data.editable_settings.whitelist,
&*read_data.editable_settings.banlist, &read_data.editable_settings.banlist,
player_count >= max_players, player_count >= max_players,
) { ) {
None => return Ok(()), None => return Ok(()),
@ -232,11 +232,11 @@ impl<'a> System<'a> for Sys {
time_of_day: *read_data.time_of_day, time_of_day: *read_data.time_of_day,
max_group_size: read_data.settings.max_player_group_size, max_group_size: read_data.settings.max_player_group_size,
client_timeout: read_data.settings.client_timeout, client_timeout: read_data.settings.client_timeout,
world_map: (&*read_data.map).clone(), world_map: (*read_data.map).clone(),
recipe_book: default_recipe_book().cloned(), recipe_book: default_recipe_book().cloned(),
component_recipe_book: default_component_recipe_book().cloned(), component_recipe_book: default_component_recipe_book().cloned(),
material_stats: (&*read_data.material_stats).clone(), material_stats: (*read_data.material_stats).clone(),
ability_map: (&*read_data.ability_map).clone(), ability_map: (*read_data.ability_map).clone(),
})?; })?;
debug!("Done initial sync with client."); debug!("Done initial sync with client.");

View File

@ -436,7 +436,7 @@ impl NpcData {
comp::Agent::from_body(&body) comp::Agent::from_body(&body)
.with_behavior( .with_behavior(
Behavior::default() Behavior::default()
.maybe_with_capabilities(can_speak.then(|| BehaviorCapability::SPEAK)) .maybe_with_capabilities(can_speak.then_some(BehaviorCapability::SPEAK))
.with_trade_site(trade_for_site), .with_trade_site(trade_for_site),
) )
.with_patrol_origin(pos) .with_patrol_origin(pos)

Some files were not shown because too many files have changed in this diff Show More