enforce lint groups

added remaining lint enforcements
This commit is contained in:
MaxOhn
2021-11-06 22:30:10 +01:00
parent 65e4ba166a
commit 21dcdeb942
16 changed files with 44 additions and 39 deletions
+2 -2
View File
@@ -55,7 +55,7 @@ impl Movement {
self.current_section_peak = self.peak_strain(time - self.prev_time.unwrap()); self.current_section_peak = self.peak_strain(time - self.prev_time.unwrap());
} }
pub(crate) fn process(&mut self, current: &DifficultyObject) { pub(crate) fn process(&mut self, current: &DifficultyObject<'_>) {
self.current_strain *= strain_decay(current.delta); self.current_strain *= strain_decay(current.delta);
self.current_strain += self.strain_value_of(current) * SKILL_MULTIPLIER; self.current_strain += self.strain_value_of(current) * SKILL_MULTIPLIER;
self.current_section_peak = self.current_strain.max(self.current_section_peak); self.current_section_peak = self.current_strain.max(self.current_section_peak);
@@ -77,7 +77,7 @@ impl Movement {
difficulty difficulty
} }
fn strain_value_of(&mut self, current: &DifficultyObject) -> f32 { fn strain_value_of(&mut self, current: &DifficultyObject<'_>) -> f32 {
let last_player_pos = self let last_player_pos = self
.last_player_position .last_player_position
.unwrap_or(current.last_normalized_pos); .unwrap_or(current.last_normalized_pos);
+6 -5
View File
@@ -134,6 +134,7 @@
//! - \[x\] async parsing //! - \[x\] async parsing
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))] #![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
#![deny(clippy::all, nonstandard_style, rust_2018_idioms, unused, warnings)]
#[cfg(feature = "fruits")] #[cfg(feature = "fruits")]
#[cfg_attr(docsrs, doc(cfg(feature = "fruits")))] #[cfg_attr(docsrs, doc(cfg(feature = "fruits")))]
@@ -194,7 +195,7 @@ pub trait BeatmapExt {
/// Returns a builder to calculate pp and difficulty values. /// Returns a builder to calculate pp and difficulty values.
/// ///
/// Convenient method that matches on the map's mode to choose the appropriate calculator. /// Convenient method that matches on the map's mode to choose the appropriate calculator.
fn pp(&self) -> AnyPP; fn pp(&self) -> AnyPP<'_>;
/// Calculate the strains of a map. /// Calculate the strains of a map.
/// This essentially performs the same calculation as a `stars` function but /// This essentially performs the same calculation as a `stars` function but
@@ -253,7 +254,7 @@ impl BeatmapExt for Beatmap {
} }
GameMode::TKO => { GameMode::TKO => {
#[cfg(not(feature = "taiko"))] #[cfg(not(feature = "taiko"))]
panic!("`osu` feature is not enabled"); panic!("`taiko` feature is not enabled");
#[cfg(feature = "taiko")] #[cfg(feature = "taiko")]
StarResult::Taiko(taiko::stars(self, mods, passed_objects)) StarResult::Taiko(taiko::stars(self, mods, passed_objects))
@@ -286,7 +287,7 @@ impl BeatmapExt for Beatmap {
} }
GameMode::TKO => { GameMode::TKO => {
#[cfg(not(feature = "taiko"))] #[cfg(not(feature = "taiko"))]
panic!("`osu` feature is not enabled"); panic!("`taiko` feature is not enabled");
#[cfg(feature = "taiko")] #[cfg(feature = "taiko")]
PpResult::Taiko(TaikoPP::new(self).mods(mods).calculate()) PpResult::Taiko(TaikoPP::new(self).mods(mods).calculate())
@@ -302,7 +303,7 @@ impl BeatmapExt for Beatmap {
} }
#[inline] #[inline]
fn pp(&self) -> AnyPP { fn pp(&self) -> AnyPP<'_> {
AnyPP::new(self) AnyPP::new(self)
} }
@@ -350,7 +351,7 @@ impl BeatmapExt for Beatmap {
} }
GameMode::TKO => { GameMode::TKO => {
#[cfg(not(feature = "taiko"))] #[cfg(not(feature = "taiko"))]
panic!("`osu` feature is not enabled"); panic!("`taiko` feature is not enabled");
#[cfg(feature = "taiko")] #[cfg(feature = "taiko")]
taiko::strains(self, mods) taiko::strains(self, mods)
+2 -2
View File
@@ -63,14 +63,14 @@ impl Strain {
} }
#[inline] #[inline]
pub(crate) fn process(&mut self, current: &DifficultyHitObject) { pub(crate) fn process(&mut self, current: &DifficultyHitObject<'_>) {
self.current_strain *= self.strain_decay(current.delta); self.current_strain *= self.strain_decay(current.delta);
self.current_strain += self.strain_value_of(current) * SKILL_MULTIPLIER; self.current_strain += self.strain_value_of(current) * SKILL_MULTIPLIER;
self.current_section_peak = self.current_strain.max(self.current_section_peak); self.current_section_peak = self.current_strain.max(self.current_section_peak);
self.prev_time.replace(current.start_time); self.prev_time.replace(current.start_time);
} }
fn strain_value_of(&mut self, current: &DifficultyHitObject) -> f32 { fn strain_value_of(&mut self, current: &DifficultyHitObject<'_>) -> f32 {
let end_time = current.base.end_time(); let end_time = current.base.end_time();
let mut hold_factor = 1.0; let mut hold_factor = 1.0;
+1 -1
View File
@@ -42,7 +42,7 @@ pub(crate) struct ObjectParameters<'a> {
impl OsuObject { impl OsuObject {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub(crate) fn new(h: &HitObject, hr: bool, params: &mut ObjectParameters) -> Option<Self> { pub(crate) fn new(h: &HitObject, hr: bool, params: &mut ObjectParameters<'_>) -> Option<Self> {
let ObjectParameters { let ObjectParameters {
map, map,
radius, radius,
+2 -2
View File
@@ -31,7 +31,7 @@ impl Skill {
} }
#[inline] #[inline]
pub(crate) fn process(&mut self, curr: &DifficultyObject) { pub(crate) fn process(&mut self, curr: &DifficultyObject<'_>) {
self.kind.pre_process(); self.kind.pre_process();
self.curr_section_peak = self.strain_value_at(curr).max(self.curr_section_peak); self.curr_section_peak = self.strain_value_at(curr).max(self.curr_section_peak);
self.prev_time = Some(curr.base.time); self.prev_time = Some(curr.base.time);
@@ -89,7 +89,7 @@ impl Skill {
} }
} }
pub(crate) fn strain_value_at(&mut self, curr: &DifficultyObject) -> f32 { pub(crate) fn strain_value_at(&mut self, curr: &DifficultyObject<'_>) -> f32 {
self.curr_strain *= self.kind.strain_decay(curr.delta); self.curr_strain *= self.kind.strain_decay(curr.delta);
self.curr_strain += self.kind.strain_value_of(curr) * self.kind.skill_multiplier(); self.curr_strain += self.kind.strain_value_of(curr) * self.kind.skill_multiplier();
+5 -5
View File
@@ -45,7 +45,7 @@ pub(crate) struct FlashlightHistoryEntry {
} }
impl From<&DifficultyObject<'_>> for FlashlightHistoryEntry { impl From<&DifficultyObject<'_>> for FlashlightHistoryEntry {
fn from(h: &DifficultyObject) -> Self { fn from(h: &DifficultyObject<'_>) -> Self {
Self { Self {
end_pos: h.base.end_pos(), end_pos: h.base.end_pos(),
is_spinner: h.base.is_spinner(), is_spinner: h.base.is_spinner(),
@@ -62,7 +62,7 @@ pub(crate) struct SpeedHistoryEntry {
} }
impl From<&DifficultyObject<'_>> for SpeedHistoryEntry { impl From<&DifficultyObject<'_>> for SpeedHistoryEntry {
fn from(h: &DifficultyObject) -> Self { fn from(h: &DifficultyObject<'_>) -> Self {
Self { Self {
is_slider: h.base.is_slider(), is_slider: h.base.is_slider(),
start_time: h.base.time, start_time: h.base.time,
@@ -108,7 +108,7 @@ impl SkillKind {
} }
} }
pub(crate) fn post_process(&mut self, current: &DifficultyObject) { pub(crate) fn post_process(&mut self, current: &DifficultyObject<'_>) {
match self { match self {
Self::Aim => {} Self::Aim => {}
Self::Flashlight { history, .. } => history.push_front(current.into()), Self::Flashlight { history, .. } => history.push_front(current.into()),
@@ -116,7 +116,7 @@ impl SkillKind {
} }
} }
pub(crate) fn strain_value_of(&self, curr: &DifficultyObject) -> f32 { pub(crate) fn strain_value_of(&self, curr: &DifficultyObject<'_>) -> f32 {
match self { match self {
Self::Aim => { Self::Aim => {
if curr.base.is_spinner() { if curr.base.is_spinner() {
@@ -286,7 +286,7 @@ impl SkillKind {
} }
pub(crate) fn calculate_speed_rhythm_bonus( pub(crate) fn calculate_speed_rhythm_bonus(
current: &DifficultyObject, current: &DifficultyObject<'_>,
history: &VecDeque<SpeedHistoryEntry>, history: &VecDeque<SpeedHistoryEntry>,
hit_window: f32, hit_window: f32,
) -> f32 { ) -> f32 {
+1 -1
View File
@@ -37,7 +37,7 @@ pub(crate) struct ObjectParameters<'a> {
} }
impl OsuObject { impl OsuObject {
pub(crate) fn new(h: &HitObject, params: &mut ObjectParameters) -> Option<Self> { pub(crate) fn new(h: &HitObject, params: &mut ObjectParameters<'_>) -> Option<Self> {
let ObjectParameters { let ObjectParameters {
map, map,
radius, radius,
+2 -2
View File
@@ -30,7 +30,7 @@ impl Skill {
} }
} }
pub(crate) fn process(&mut self, curr: &DifficultyObject) { pub(crate) fn process(&mut self, curr: &DifficultyObject<'_>) {
self.kind.pre_process(); self.kind.pre_process();
self.curr_section_peak = self.strain_value_at(curr).max(self.curr_section_peak); self.curr_section_peak = self.strain_value_at(curr).max(self.curr_section_peak);
self.prev_time = Some(curr.base.time); self.prev_time = Some(curr.base.time);
@@ -88,7 +88,7 @@ impl Skill {
} }
} }
pub(crate) fn strain_value_at(&mut self, curr: &DifficultyObject) -> f32 { pub(crate) fn strain_value_at(&mut self, curr: &DifficultyObject<'_>) -> f32 {
self.curr_strain *= self.kind.strain_decay(curr.delta); self.curr_strain *= self.kind.strain_decay(curr.delta);
self.curr_strain += self.kind.strain_value_of(curr) * self.kind.skill_multiplier(); self.curr_strain += self.kind.strain_value_of(curr) * self.kind.skill_multiplier();
+5 -5
View File
@@ -45,7 +45,7 @@ pub(crate) struct FlashlightHistoryEntry {
} }
impl From<&DifficultyObject<'_>> for FlashlightHistoryEntry { impl From<&DifficultyObject<'_>> for FlashlightHistoryEntry {
fn from(h: &DifficultyObject) -> Self { fn from(h: &DifficultyObject<'_>) -> Self {
Self { Self {
end_pos: h.base.end_pos(), end_pos: h.base.end_pos(),
is_spinner: h.base.is_spinner(), is_spinner: h.base.is_spinner(),
@@ -62,7 +62,7 @@ pub(crate) struct SpeedHistoryEntry {
} }
impl From<&DifficultyObject<'_>> for SpeedHistoryEntry { impl From<&DifficultyObject<'_>> for SpeedHistoryEntry {
fn from(h: &DifficultyObject) -> Self { fn from(h: &DifficultyObject<'_>) -> Self {
Self { Self {
is_slider: h.base.is_slider(), is_slider: h.base.is_slider(),
start_time: h.base.time, start_time: h.base.time,
@@ -108,7 +108,7 @@ impl SkillKind {
} }
} }
pub(crate) fn post_process(&mut self, current: &DifficultyObject) { pub(crate) fn post_process(&mut self, current: &DifficultyObject<'_>) {
match self { match self {
Self::Aim => {} Self::Aim => {}
Self::Flashlight { history, .. } => history.push_front(current.into()), Self::Flashlight { history, .. } => history.push_front(current.into()),
@@ -116,7 +116,7 @@ impl SkillKind {
} }
} }
pub(crate) fn strain_value_of(&self, curr: &DifficultyObject) -> f32 { pub(crate) fn strain_value_of(&self, curr: &DifficultyObject<'_>) -> f32 {
match self { match self {
Self::Aim => { Self::Aim => {
if curr.base.is_spinner() { if curr.base.is_spinner() {
@@ -286,7 +286,7 @@ impl SkillKind {
} }
pub(crate) fn calculate_speed_rhythm_bonus( pub(crate) fn calculate_speed_rhythm_bonus(
current: &DifficultyObject, current: &DifficultyObject<'_>,
history: &VecDeque<SpeedHistoryEntry>, history: &VecDeque<SpeedHistoryEntry>,
hit_window: f32, hit_window: f32,
) -> f32 { ) -> f32 {
@@ -31,7 +31,7 @@ impl Skill {
} }
#[inline] #[inline]
pub(crate) fn process(&mut self, curr: &DifficultyObject) { pub(crate) fn process(&mut self, curr: &DifficultyObject<'_>) {
self.kind.pre_process(); self.kind.pre_process();
self.curr_section_peak = self.strain_value_at(curr).max(self.curr_section_peak); self.curr_section_peak = self.strain_value_at(curr).max(self.curr_section_peak);
self.prev_time = Some(curr.base.time); self.prev_time = Some(curr.base.time);
@@ -89,7 +89,7 @@ impl Skill {
} }
} }
pub(crate) fn strain_value_at(&mut self, curr: &DifficultyObject) -> f32 { pub(crate) fn strain_value_at(&mut self, curr: &DifficultyObject<'_>) -> f32 {
self.curr_strain *= self.kind.strain_decay(curr.delta); self.curr_strain *= self.kind.strain_decay(curr.delta);
self.curr_strain += self.kind.strain_value_of(curr) * self.kind.skill_multiplier(); self.curr_strain += self.kind.strain_value_of(curr) * self.kind.skill_multiplier();
@@ -45,7 +45,7 @@ pub(crate) struct FlashlightHistoryEntry {
} }
impl From<&DifficultyObject<'_>> for FlashlightHistoryEntry { impl From<&DifficultyObject<'_>> for FlashlightHistoryEntry {
fn from(h: &DifficultyObject) -> Self { fn from(h: &DifficultyObject<'_>) -> Self {
Self { Self {
end_pos: h.base.pos, end_pos: h.base.pos,
is_spinner: h.base.is_spinner, is_spinner: h.base.is_spinner,
@@ -62,7 +62,7 @@ pub(crate) struct SpeedHistoryEntry {
} }
impl From<&DifficultyObject<'_>> for SpeedHistoryEntry { impl From<&DifficultyObject<'_>> for SpeedHistoryEntry {
fn from(h: &DifficultyObject) -> Self { fn from(h: &DifficultyObject<'_>) -> Self {
Self { Self {
is_slider: h.base.is_slider, is_slider: h.base.is_slider,
start_time: h.base.time, start_time: h.base.time,
@@ -108,7 +108,7 @@ impl SkillKind {
} }
} }
pub(crate) fn post_process(&mut self, current: &DifficultyObject) { pub(crate) fn post_process(&mut self, current: &DifficultyObject<'_>) {
match self { match self {
Self::Aim => {} Self::Aim => {}
Self::Flashlight { history, .. } => history.push_front(current.into()), Self::Flashlight { history, .. } => history.push_front(current.into()),
@@ -116,7 +116,7 @@ impl SkillKind {
} }
} }
pub(crate) fn strain_value_of(&self, curr: &DifficultyObject) -> f32 { pub(crate) fn strain_value_of(&self, curr: &DifficultyObject<'_>) -> f32 {
match self { match self {
Self::Aim => { Self::Aim => {
if curr.base.is_spinner { if curr.base.is_spinner {
@@ -282,7 +282,7 @@ impl SkillKind {
} }
pub(crate) fn calculate_speed_rhythm_bonus( pub(crate) fn calculate_speed_rhythm_bonus(
current: &DifficultyObject, current: &DifficultyObject<'_>,
history: &VecDeque<SpeedHistoryEntry>, history: &VecDeque<SpeedHistoryEntry>,
hit_window: f32, hit_window: f32,
) -> f32 { ) -> f32 {
+1 -1
View File
@@ -41,7 +41,7 @@ pub enum ParseError {
} }
impl fmt::Display for ParseError { impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::IOError(_) => f.write_str("IO error"), Self::IOError(_) => f.write_str("IO error"),
Self::IncorrectFileHeader => { Self::IncorrectFileHeader => {
+3 -3
View File
@@ -98,13 +98,13 @@ impl ops::AddAssign for Pos2 {
} }
impl fmt::Display for Pos2 { impl fmt::Display for Pos2 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self) fmt::Debug::fmt(self, f)
} }
} }
impl fmt::Debug for Pos2 { impl fmt::Debug for Pos2 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y) write!(f, "({}, {})", self.x, self.y)
} }
} }
+1 -1
View File
@@ -55,7 +55,7 @@ impl<T> LimitedQueue<T> {
} }
#[inline] #[inline]
pub(crate) fn iter(&self) -> LimitedQueueIter<T> { pub(crate) fn iter(&self) -> LimitedQueueIter<'_, T> {
let iter = self let iter = self
.queue .queue
.iter() .iter()
+1 -1
View File
@@ -48,7 +48,7 @@ impl Skill {
} }
#[inline] #[inline]
pub(crate) fn process(&mut self, current: &DifficultyObject, cheese: &[bool]) { pub(crate) fn process(&mut self, current: &DifficultyObject<'_>, cheese: &[bool]) {
self.current_strain *= self.strain_decay(current.delta); self.current_strain *= self.strain_decay(current.delta);
self.current_strain += self.kind.strain_value_of(current, cheese) * self.skill_multiplier(); self.current_strain += self.kind.strain_value_of(current, cheese) * self.skill_multiplier();
self.current_section_peak = self.current_section_peak.max(self.current_strain); self.current_section_peak = self.current_section_peak.max(self.current_strain);
+5 -1
View File
@@ -55,7 +55,11 @@ impl SkillKind {
} }
} }
pub(crate) fn strain_value_of(&mut self, current: &DifficultyObject, cheese: &[bool]) -> f32 { pub(crate) fn strain_value_of(
&mut self,
current: &DifficultyObject<'_>,
cheese: &[bool],
) -> f32 {
match self { match self {
Self::Color { Self::Color {
mono_history, mono_history,