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