Another round of manual linting
Some checks failed
Build and Test / Format check (push) Has been cancelled
Build and Test / Lint (push) Has been cancelled
Build and Test / Test (push) Has been cancelled
Build and Test / Check dependency hash (push) Has been cancelled
Build and Test / Build (push) Has been cancelled

This commit is contained in:
Natsu Kagami 2025-05-13 00:58:28 +02:00
parent c5f46dd7fe
commit a4ac2b9e2c
Signed by: nki
GPG key ID: 55A032EB38B49ADB
8 changed files with 38 additions and 38 deletions

View file

@ -11,3 +11,6 @@ members = [
]
[workspace.lints.rust]
deprecated = "allow"
[workspace.lints.clippy]
too_many_arguments = "allow"

View file

@ -188,7 +188,7 @@ impl OsuUser {
impl OsuUser {
/// Stores the user.
pub async fn store<'a>(&self, conn: &mut Transaction<'a, Database>) -> Result<bool> {
pub async fn store(&self, conn: &mut Transaction<'_, Database>) -> Result<bool> {
let old_user_id = {
query!(
r#"SELECT id as "id: i64" FROM osu_users WHERE user_id = ?"#,

View file

@ -337,7 +337,7 @@ async fn beatmap<U: HasOsuEnv>(
EmbedType::Beatmap(beatmap, bmode, info, bmmods) => {
let (beatmap, info, mods) =
if mods.is_none() && mode.is_none_or(|v| v == bmode.unwrap_or(beatmap.mode)) {
(*beatmap, info, bmmods)
(*beatmap, *info, bmmods)
} else {
let mode = bmode.unwrap_or(beatmap.mode);
let mods = match mods {
@ -678,7 +678,7 @@ async fn parse_map_input(
return Ok(EmbedType::Beatmap(
Box::new(beatmap),
None,
info,
Box::new(info),
Mods::NOMOD.clone(),
));
}

View file

@ -194,7 +194,7 @@ mod scores {
header: header.clone(),
scores,
};
let Some(content) = p.to_table(0, usize::max_value()).await? else {
let Some(content) = p.format_table(0, usize::MAX).await? else {
on.apply_edit(CreateReply::default().content("No plays found"))
.await?;
return Ok(());
@ -240,7 +240,7 @@ mod scores {
}
impl<T: Scores> Paginate<T> {
async fn to_table(&mut self, start: usize, end: usize) -> Result<Option<String>> {
async fn format_table(&mut self, start: usize, end: usize) -> Result<Option<String>> {
let scores = self.scores.get_range(start..end).await?;
if scores.is_empty() {
return Ok(None);
@ -374,7 +374,7 @@ mod scores {
let start = page * ITEMS_PER_PAGE;
let end = start + ITEMS_PER_PAGE;
let Some(score_table) = self.to_table(start, end).await? else {
let Some(score_table) = self.format_table(start, end).await? else {
return Ok(None);
};
let mut content = serenity::utils::MessageBuilder::new();

View file

@ -254,7 +254,7 @@ pub fn hook<'a>(
.then(|l| async move {
match l.embed {
EmbedType::Beatmap(b, mode, info, mods) => {
handle_beatmap(ctx, &b, info, l.link, mode, mods, msg)
handle_beatmap(ctx, &b, *info, l.link, mode, mods, msg)
.await
.pls_ok();
let bm = super::BeatmapWithMode(*b, mode);
@ -277,7 +277,7 @@ pub fn hook<'a>(
})
}
async fn handle_beatmap<'a, 'b>(
async fn handle_beatmap(
ctx: &Context,
beatmap: &Beatmap,
info: BeatmapInfoWithPP,
@ -316,7 +316,7 @@ async fn handle_beatmap<'a, 'b>(
Ok(())
}
async fn handle_beatmapset<'a, 'b>(
async fn handle_beatmapset(
ctx: &Context,
beatmaps: Vec<Beatmap>,
link: &'_ str,

View file

@ -11,7 +11,7 @@ use super::{oppai_cache::BeatmapInfoWithPP, OsuEnv};
#[derive(Debug, Clone)]
pub enum EmbedType {
Beatmap(Box<Beatmap>, Option<Mode>, BeatmapInfoWithPP, Mods),
Beatmap(Box<Beatmap>, Option<Mode>, Box<BeatmapInfoWithPP>, Mods),
Beatmapset(Vec<Beatmap>, Option<Mode>),
}
@ -166,7 +166,7 @@ impl EmbedType {
.await
.map(|b| b.get_possible_pp_with(mode, &mods))?
};
Ok(Self::Beatmap(Box::new(bm), mode, info, mods))
Ok(Self::Beatmap(Box::new(bm), mode, Box::new(info), mods))
}
pub(crate) async fn from_beatmapset_id(

View file

@ -449,31 +449,28 @@ pub async fn forcesave(ctx: &Context, msg: &Message, mut args: Args) -> CommandR
async fn add_user(target: serenity::model::id::UserId, user: &User, env: &OsuEnv) -> Result<()> {
let modes = [Mode::Std, Mode::Taiko, Mode::Catch, Mode::Mania]
.into_iter()
.map(|mode| {
let mode = mode;
async move {
let pp = async {
env.client
.user(&UserID::ID(user.id), |f| f.mode(mode))
.await
.pls_ok()
.unwrap_or(None)
.and_then(|u| u.pp)
};
let map_length_age = UserExtras::from_user(env, user, mode);
let (pp, ex) = join!(pp, map_length_age);
pp.zip(ex.ok()).map(|(pp, ex)| {
(
mode,
OsuUserMode {
pp,
map_length: ex.map_length,
map_age: ex.map_age,
last_update: Utc::now(),
},
)
})
}
.map(|mode| async move {
let pp = async {
env.client
.user(&UserID::ID(user.id), |f| f.mode(mode))
.await
.pls_ok()
.unwrap_or(None)
.and_then(|u| u.pp)
};
let map_length_age = UserExtras::from_user(env, user, mode);
let (pp, ex) = join!(pp, map_length_age);
pp.zip(ex.ok()).map(|(pp, ex)| {
(
mode,
OsuUserMode {
pp,
map_length: ex.map_length,
map_age: ex.map_age,
last_update: Utc::now(),
},
)
})
})
.collect::<stream::FuturesOrdered<_>>()
.filter_map(future::ready)
@ -832,7 +829,7 @@ pub(crate) async fn load_beatmap_from_channel(
Some(EmbedType::Beatmap(
Box::new(b),
m,
info,
Box::new(info),
Mods::NOMOD.clone(),
))
}

View file

@ -160,7 +160,7 @@ impl<T: FetchScores> Scores for ScoresFetcher<T> {
/// Get all scores.
async fn get_all(mut self) -> Result<Vec<Score>> {
let _ = self.get_range(0..usize::max_value()).await?;
let _ = self.get_range(0..usize::MAX).await?;
Ok(self.scores)
}