From a636405bed334b1eed270c8e8289011ad7f57554 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Tue, 14 May 2024 18:41:37 -0700 Subject: [PATCH] enable `needless_pass_by_value` lint --- Cargo.toml | 1 + src/api/client_server/relations.rs | 6 +++--- src/service/rooms/pdu_metadata.rs | 12 ++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7c267517..18d3a397 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ missing_assert_message = "warn" mod_module_files = "warn" multiple_inherent_impl = "warn" mutex_atomic = "warn" +needless_pass_by_value = "warn" negative_feature_names = "warn" pub_without_shorthand = "warn" rc_buffer = "warn" diff --git a/src/api/client_server/relations.rs b/src/api/client_server/relations.rs index bb85641b..353e4cc7 100644 --- a/src/api/client_server/relations.rs +++ b/src/api/client_server/relations.rs @@ -43,8 +43,8 @@ pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route( sender_user, &body.room_id, &body.event_id, - Some(body.event_type.clone()), - Some(body.rel_type.clone()), + Some(&body.event_type), + Some(&body.rel_type), from, to, limit, @@ -95,7 +95,7 @@ pub(crate) async fn get_relating_events_with_rel_type_route( &body.room_id, &body.event_id, None, - Some(body.rel_type.clone()), + Some(&body.rel_type), from, to, limit, diff --git a/src/service/rooms/pdu_metadata.rs b/src/service/rooms/pdu_metadata.rs index ee904e07..69049ad6 100644 --- a/src/service/rooms/pdu_metadata.rs +++ b/src/service/rooms/pdu_metadata.rs @@ -46,8 +46,8 @@ impl Service { sender_user: &UserId, room_id: &RoomId, target: &EventId, - filter_event_type: Option, - filter_rel_type: Option, + filter_event_type: Option<&TimelineEventType>, + filter_rel_type: Option<&RelationType>, from: PduCount, to: Option, limit: usize, @@ -63,7 +63,7 @@ impl Service { .relations_until(sender_user, room_id, target, from)? // TODO: should be relations_after .filter(|r| { r.as_ref().map_or(true, |(_, pdu)| { - filter_event_type.as_ref().map_or(true, |t| &pdu.kind == t) + filter_event_type.as_ref().map_or(true, |t| &&pdu.kind == t) && if let Ok(content) = serde_json::from_str::( pdu.content.get(), @@ -71,7 +71,7 @@ impl Service { { filter_rel_type .as_ref() - .map_or(true, |r| &content.relates_to.rel_type == r) + .map_or(true, |r| &&content.relates_to.rel_type == r) } else { false } @@ -110,7 +110,7 @@ impl Service { .relations_until(sender_user, room_id, target, from)? .filter(|r| { r.as_ref().map_or(true, |(_, pdu)| { - filter_event_type.as_ref().map_or(true, |t| &pdu.kind == t) + filter_event_type.as_ref().map_or(true, |t| &&pdu.kind == t) && if let Ok(content) = serde_json::from_str::( pdu.content.get(), @@ -118,7 +118,7 @@ impl Service { { filter_rel_type .as_ref() - .map_or(true, |r| &content.relates_to.rel_type == r) + .map_or(true, |r| &&content.relates_to.rel_type == r) } else { false }