From cde6fdd74132b1943c4befb2b2d6d72aa46e5e10 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sat, 2 Mar 2024 17:09:10 -0500 Subject: [PATCH] resolve or_fun_call clippy lint Signed-off-by: strawberry --- Cargo.toml | 2 +- src/api/client_server/report.rs | 4 ++-- src/api/client_server/session.rs | 2 +- src/api/client_server/sync.rs | 13 +++++++++---- src/service/admin/mod.rs | 2 +- src/service/sending/mod.rs | 5 ++++- src/service/users/mod.rs | 6 +++--- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a91d37fc..81e77bd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -257,5 +257,5 @@ unseparated_literal_suffix = "warn" # unwrap_used = "warn" # expect_used = "warn" wildcard_dependencies = "warn" -# or_fun_call = "warn" +or_fun_call = "warn" unnecessary_lazy_evaluations = "warn" diff --git a/src/api/client_server/report.rs b/src/api/client_server/report.rs index 3872e882..4d0921e7 100644 --- a/src/api/client_server/report.rs +++ b/src/api/client_server/report.rs @@ -86,7 +86,7 @@ pub async fn report_event_route( pdu.event_id, pdu.room_id, pdu.sender.to_owned(), - body.score.unwrap_or(ruma::Int::from(0)), + body.score.unwrap_or_else(|| ruma::Int::from(0)), body.reason.as_deref().unwrap_or("") ), format!( @@ -100,7 +100,7 @@ pub async fn report_event_route( pdu.event_id.to_owned(), pdu.room_id.to_owned(), pdu.sender.to_owned(), - body.score.unwrap_or(ruma::Int::from(0)), + body.score.unwrap_or_else(|| ruma::Int::from(0)), HtmlEscape(body.reason.as_deref().unwrap_or("")) ), )); diff --git a/src/api/client_server/session.rs b/src/api/client_server/session.rs index b5e80001..a5181d59 100644 --- a/src/api/client_server/session.rs +++ b/src/api/client_server/session.rs @@ -215,7 +215,7 @@ pub async fn login_route(body: Ruma) -> Result { list_filters.is_dm = list_filters.is_dm.or(cached_filters.is_dm); @@ -168,13 +168,13 @@ impl Service { .account_data .lists .clone() - .or(cached.extensions.account_data.lists.clone()); + .or_else(|| cached.extensions.account_data.lists.clone()); request.extensions.account_data.rooms = request .extensions .account_data .rooms .clone() - .or(cached.extensions.account_data.rooms.clone()); + .or_else(|| cached.extensions.account_data.rooms.clone()); cached.extensions = request.extensions.clone();