diff --git a/src/any/difficulty/mod.rs b/src/any/difficulty/mod.rs index a5aa1f3a..25e05fed 100644 --- a/src/any/difficulty/mod.rs +++ b/src/any/difficulty/mod.rs @@ -385,7 +385,7 @@ impl Difficulty { } } -fn non_zero_u64_to_f64(n: NonZeroU64) -> f64 { +const fn non_zero_u64_to_f64(n: NonZeroU64) -> f64 { f64::from_bits(n.get()) } diff --git a/src/catch/difficulty/skills/movement.rs b/src/catch/difficulty/skills/movement.rs index b2353ad1..5d6d04a0 100644 --- a/src/catch/difficulty/skills/movement.rs +++ b/src/catch/difficulty/skills/movement.rs @@ -131,7 +131,7 @@ impl ISkill for Movement { type DifficultyObjects<'a> = [CatchDifficultyObject]; } -impl<'a> Skill<'a, Movement> { +impl Skill<'_, Movement> { fn calculate_initial_strain(&mut self, time: f64, curr: &CatchDifficultyObject) -> f64 { let prev_start_time = curr .previous(0, self.diff_objects) diff --git a/src/osu/difficulty/skills/aim.rs b/src/osu/difficulty/skills/aim.rs index 32537fd2..e17611e4 100644 --- a/src/osu/difficulty/skills/aim.rs +++ b/src/osu/difficulty/skills/aim.rs @@ -133,7 +133,9 @@ impl AimEvaluator { return 0.0; }; + #[allow(clippy::items_after_statements)] const RADIUS: i32 = OsuDifficultyObject::NORMALIZED_RADIUS; + #[allow(clippy::items_after_statements)] const DIAMETER: i32 = OsuDifficultyObject::NORMALIZED_DIAMETER; // * Calculate the velocity to the current hitobject, which starts diff --git a/src/osu/difficulty/skills/speed.rs b/src/osu/difficulty/skills/speed.rs index c1255801..f596450b 100644 --- a/src/osu/difficulty/skills/speed.rs +++ b/src/osu/difficulty/skills/speed.rs @@ -135,9 +135,7 @@ impl<'a> Skill<'a, Speed> { self.inner.curr_rhythm = RhythmEvaluator::evaluate_diff_of(curr, self.diff_objects, self.inner.hit_window); - let total_strain = self.inner.curr_strain * self.inner.curr_rhythm; - - total_strain + self.inner.curr_strain * self.inner.curr_rhythm } } diff --git a/src/osu/difficulty/skills/strain.rs b/src/osu/difficulty/skills/strain.rs index 861eb36c..7497525e 100644 --- a/src/osu/difficulty/skills/strain.rs +++ b/src/osu/difficulty/skills/strain.rs @@ -1,18 +1,10 @@ use crate::any::difficulty::skills::{DifficultyValue, StrainSkill, UsedStrainSkills}; -#[derive(Clone)] +#[derive(Clone, Default)] pub struct OsuStrainSkill { pub inner: StrainSkill, } -impl Default for OsuStrainSkill { - fn default() -> Self { - Self { - inner: StrainSkill::default(), - } - } -} - impl OsuStrainSkill { pub const REDUCED_SECTION_COUNT: usize = 10; pub const REDUCED_STRAIN_BASELINE: f64 = 0.75; diff --git a/src/osu/performance/mod.rs b/src/osu/performance/mod.rs index af0214e4..02ec3ca9 100644 --- a/src/osu/performance/mod.rs +++ b/src/osu/performance/mod.rs @@ -765,9 +765,7 @@ impl<'map> OsuPerformance<'map> { match map { Cow::Borrowed(map) => match map.convert_ref(mode, mods) { Ok(map) => Ok(map), - Err(_) => { - return Err(MapOrAttrs::Map(Cow::Borrowed(map))); - } + Err(_) => Err(MapOrAttrs::Map(Cow::Borrowed(map))), }, Cow::Owned(mut map) => { if map.convert_mut(mode, mods).is_err() { diff --git a/src/util/map_or_attrs.rs b/src/util/map_or_attrs.rs index a5f9e34b..bbac3e55 100644 --- a/src/util/map_or_attrs.rs +++ b/src/util/map_or_attrs.rs @@ -10,7 +10,7 @@ pub enum MapOrAttrs<'map, M: IGameMode> { Attrs(M::DifficultyAttributes), } -impl<'map, M: IGameMode> MapOrAttrs<'map, M> { +impl MapOrAttrs<'_, M> { /// Return a mutable reference to the attributes. /// /// If `self` is of variant `Map`, store `attrs` in `self`, and return a diff --git a/src/util/strains_vec.rs b/src/util/strains_vec.rs index c46495ef..2e615a15 100644 --- a/src/util/strains_vec.rs +++ b/src/util/strains_vec.rs @@ -151,7 +151,7 @@ mod inner { } } - impl<'a> Iterator for StrainsIter<'a> { + impl Iterator for StrainsIter<'_> { type Item = f64; fn next(&mut self) -> Option { @@ -219,14 +219,14 @@ mod inner { } } - pub fn is_zero(self) -> bool { + pub const fn is_zero(self) -> bool { unsafe { self.value.is_sign_negative() } } // Requiring `self` as a reference improves ergonomics for passing this // method as argument to higher-order functions. #[allow(clippy::trivially_copy_pass_by_ref)] - pub fn is_value(&self) -> bool { + pub const fn is_value(&self) -> bool { !self.is_zero() }