made clippy happy

This commit is contained in:
MaxOhn
2024-02-22 20:35:58 +01:00
parent 8f299af49f
commit ae14815140
11 changed files with 21 additions and 47 deletions
+1
View File
@@ -20,6 +20,7 @@ pub mod skills;
/// Difficulty calculator on maps of any mode.
#[derive(Clone, Debug, PartialEq)]
#[must_use]
pub struct Difficulty<'map> {
map: Cow<'map, Beatmap>,
is_convert: bool,
+4 -3
View File
@@ -5,6 +5,7 @@ use crate::{
/// Difficulty calculator on maps of a given mode.
#[derive(Clone, Debug, Default, PartialEq)]
#[must_use]
pub struct ModeDifficulty {
mods: u32,
passed_objects: Option<u32>,
@@ -20,12 +21,12 @@ impl ModeDifficulty {
/// Specify mods through their bit values.
///
/// See [https://github.com/ppy/osu-api/wiki#mods](https://github.com/ppy/osu-api/wiki#mods)
pub fn mods(self, mods: u32) -> Self {
pub const fn mods(self, mods: u32) -> Self {
Self { mods, ..self }
}
/// Amount of passed objects for partial plays, e.g. a fail.
pub fn passed_objects(self, passed_objects: u32) -> Self {
pub const fn passed_objects(self, passed_objects: u32) -> Self {
Self {
passed_objects: Some(passed_objects),
..self
@@ -36,7 +37,7 @@ impl ModeDifficulty {
///
/// If none is specified, it will take the clock rate based on the mods
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
pub fn clock_rate(self, clock_rate: f64) -> Self {
pub const fn clock_rate(self, clock_rate: f64) -> Self {
Self {
clock_rate: Some(clock_rate),
..self
+1 -1
View File
@@ -79,7 +79,7 @@ pub fn convert_objects(
// sort. After that, we unsort the objects again and then apply a stable
// sort to have the correct order for generating difficulty objects.
// Required e.g. due to map /b/102923.
let mut sorter = TandemSorter::new_unstable(&mut palpable_objects, |a, b| {
let mut sorter = TandemSorter::new_unstable(&palpable_objects, |a, b| {
a.start_time.total_cmp(&b.start_time)
});
+8 -21
View File
@@ -1,5 +1,3 @@
use std::fmt::{Debug, Formatter, Result as FmtResult};
use crate::{
any::difficulty::skills::Skill,
mania::{object::ObjectParams, ManiaBeatmap},
@@ -52,25 +50,13 @@ use super::{
/// [`ManiaGradualPerformance`]: crate::mania::ManiaGradualPerformance
pub struct ManiaGradualDifficulty<'map> {
pub(crate) idx: usize,
pub(crate) mods: u32,
pub(crate) clock_rate: f64,
converted: ManiaBeatmap<'map>,
strain: Strain,
diff_objects: Box<[ManiaDifficultyObject]>,
hit_window: f64,
curr_combo: u32,
pub(crate) mods: u32,
pub(crate) clock_rate: f64,
}
impl Debug for ManiaGradualDifficulty<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
f.debug_struct("ManiaGradualDifficulty")
.field("idx", &self.idx)
.field("hit_windows", &self.hit_window)
.field("curr_combo", &self.curr_combo)
.field("mods", &self.mods)
.field("clock_rate", &self.clock_rate)
.finish()
}
}
impl<'map> ManiaGradualDifficulty<'map> {
@@ -114,13 +100,13 @@ impl<'map> ManiaGradualDifficulty<'map> {
Self {
idx: 0,
mods,
clock_rate,
converted,
strain,
diff_objects,
hit_window,
curr_combo,
mods,
clock_rate,
}
}
}
@@ -129,9 +115,10 @@ impl Iterator for ManiaGradualDifficulty<'_> {
type Item = ManiaDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> {
// The first difficulty object belongs to the second note since each difficulty
// object requires the current and the last note. Hence, if we're still on the first
// object, we don't have a difficulty object yet and just skip processing.
// The first difficulty object belongs to the second note since each
// difficulty object requires the current and the last note. Hence, if
// we're still on the first object, we don't have a difficulty object
// yet and just skip processing.
if self.idx > 0 {
let curr = self.diff_objects.get(self.idx - 1)?;
Skill::new(&mut self.strain, &self.diff_objects).process(curr);
-1
View File
@@ -69,7 +69,6 @@ use super::{ManiaPerformanceAttributes, ManiaScoreState};
///
/// [`next`]: ManiaGradualPerformance::next
/// [`nth`]: ManiaGradualPerformance::nth
#[derive(Debug)]
pub struct ManiaGradualPerformance<'map> {
difficulty: ManiaGradualDifficulty<'map>,
}
+1
View File
@@ -507,6 +507,7 @@ impl DecodeBeatmap for Beatmap {
Ok(())
}
#[allow(clippy::too_many_lines)]
fn parse_hit_objects(state: &mut Self::State, line: &str) -> Result<(), Self::Error> {
let mut split = line.trim_comment().split(',');
+2 -16
View File
@@ -1,7 +1,4 @@
use std::{
fmt::{Debug, Formatter, Result as FmtResult},
mem,
};
use std::mem;
use crate::{
any::difficulty::skills::Skill,
@@ -74,17 +71,6 @@ pub struct OsuGradualDifficulty {
struct NotClonable;
impl Debug for OsuGradualDifficulty {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
f.debug_struct("OsuGradualDifficulty")
.field("idx", &self.idx)
.field("mods", &self.mods)
.field("clock_rate", &self.clock_rate)
.field("attrs", &self.attrs)
.finish()
}
}
impl OsuGradualDifficulty {
/// Create a new difficulty attributes iterator for osu!standard maps.
pub fn new(difficulty: &ModeDifficulty, converted: &OsuBeatmap<'_>) -> Self {
@@ -96,7 +82,7 @@ impl OsuGradualDifficulty {
map_attrs,
mut attrs,
time_preempt,
} = OsuDifficultySetup::new(&difficulty, converted);
} = OsuDifficultySetup::new(difficulty, converted);
let osu_objects = convert_objects(
converted,
+1 -1
View File
@@ -244,7 +244,7 @@ impl DifficultyValues {
last_last.as_deref(),
clock_rate,
idx,
&scaling_factor,
scaling_factor,
);
last_last = Some(last);
-1
View File
@@ -79,7 +79,6 @@ use super::{OsuPerformanceAttributes, OsuScoreState};
///
/// [`next`]: OsuGradualPerformance::next
/// [`nth`]: OsuGradualPerformance::nth
#[derive(Debug)]
pub struct OsuGradualPerformance {
difficulty: OsuGradualDifficulty,
}
+2 -2
View File
@@ -2,8 +2,8 @@ pub trait FloatExt: Sized {
/// Workaround since rust rounds ties away from 0.0
/// while C# rounds them to the nearest even integer.
/// See github
/// - https://github.com/rust-lang/rust/issues/96710
/// - https://github.com/rust-lang/rust/pull/82273
/// - <https://github.com/rust-lang/rust/issues/96710>
/// - <https://github.com/rust-lang/rust/pull/82273>
fn round_even(self) -> Self;
/// `self == other`
+1 -1
View File
@@ -53,6 +53,6 @@ where
fn swap<T>(keys: &mut [T], i: usize, j: usize) {
if i != j {
keys.swap(i, j)
keys.swap(i, j);
}
}