mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 17:20:49 +00:00
Simplify from_user with and_then
This commit is contained in:
parent
dde78b32d3
commit
7e68da975b
1 changed files with 7 additions and 11 deletions
|
@ -502,17 +502,13 @@ pub(crate) struct UserExtras {
|
|||
impl UserExtras {
|
||||
// Collect UserExtras from the given user.
|
||||
pub async fn from_user(env: &OsuEnv, user: &User, mode: Mode) -> Result<Self> {
|
||||
let scores = {
|
||||
match env
|
||||
let scores = env
|
||||
.client
|
||||
.user_best(UserID::ID(user.id), |f| f.mode(mode))
|
||||
.and_then(|v| v.get_all())
|
||||
.await
|
||||
.pls_ok()
|
||||
{
|
||||
Some(v) => v.get_all().await.pls_ok().unwrap_or_else(Vec::new),
|
||||
None => Vec::new(),
|
||||
}
|
||||
};
|
||||
.unwrap_or_else(Vec::new);
|
||||
|
||||
let (length, age) = join!(
|
||||
calculate_weighted_map_length(&scores, &env.beatmaps, mode),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue