Skip to content

Commit

Permalink
chore: made clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn committed Dec 26, 2024
1 parent 5d4223d commit d5c85ed
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/any/difficulty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/catch/difficulty/skills/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/osu/difficulty/skills/aim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/osu/difficulty/skills/speed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
10 changes: 1 addition & 9 deletions src/osu/difficulty/skills/strain.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/osu/performance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/util/map_or_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum MapOrAttrs<'map, M: IGameMode> {
Attrs(M::DifficultyAttributes),
}

impl<'map, M: IGameMode> MapOrAttrs<'map, M> {
impl<M: IGameMode> MapOrAttrs<'_, M> {
/// Return a mutable reference to the attributes.
///
/// If `self` is of variant `Map`, store `attrs` in `self`, and return a
Expand Down
6 changes: 3 additions & 3 deletions src/util/strains_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod inner {
}
}

impl<'a> Iterator for StrainsIter<'a> {
impl Iterator for StrainsIter<'_> {
type Item = f64;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit d5c85ed

Please sign in to comment.