resolve some pedantic lints, reduce some allocations

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-08 11:48:52 -05:00 committed by June
parent 507baf20fa
commit 496a9c7af8
12 changed files with 72 additions and 72 deletions

View file

@ -806,10 +806,7 @@ async fn join_room_by_id_helper(
let restriction_rooms = match join_rules_event_content {
Some(RoomJoinRulesEventContent {
join_rule: JoinRule::Restricted(restricted),
})
| Some(RoomJoinRulesEventContent {
join_rule: JoinRule::KnockRestricted(restricted),
join_rule: JoinRule::Restricted(restricted) | JoinRule::KnockRestricted(restricted),
}) => restricted
.allow
.into_iter()

View file

@ -28,8 +28,8 @@ pub 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.clone()),
&Some(body.rel_type.clone()),
from,
to,
limit,
@ -66,8 +66,8 @@ pub async fn get_relating_events_with_rel_type_route(
sender_user,
&body.room_id,
&body.event_id,
None,
Some(body.rel_type.clone()),
&None,
&Some(body.rel_type.clone()),
from,
to,
limit,
@ -104,8 +104,8 @@ pub async fn get_relating_events_route(
sender_user,
&body.room_id,
&body.event_id,
None,
None,
&None,
&None,
from,
to,
limit,

View file

@ -470,7 +470,7 @@ async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDe
}
async fn query_srv_record(hostname: &'_ str) -> Option<FedDest> {
fn handle_successful_srv(srv: SrvLookup) -> Option<FedDest> {
fn handle_successful_srv(srv: &SrvLookup) -> Option<FedDest> {
srv.iter().next().map(|result| {
FedDest::Named(
result.target().to_string().trim_end_matches('.').to_owned(),
@ -493,7 +493,7 @@ async fn query_srv_record(hostname: &'_ str) -> Option<FedDest> {
info!("Querying deprecated _matrix SRV record for host {:?}", hostname);
lookup_srv(&second_hostname)
})
.and_then(|srv_lookup| async { Ok(handle_successful_srv(srv_lookup)) })
.and_then(|srv_lookup| async move { Ok(handle_successful_srv(&srv_lookup)) })
.await
.ok()
.flatten()