enable as_conversions lint

There were some very, uh, creative (and inconsistent) ways to convert
between numeric types in here...
This commit is contained in:
Charles Hall 2024-05-12 15:32:23 -07:00
parent a78bf8f50b
commit 71c48f66c4
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
21 changed files with 195 additions and 91 deletions

View file

@ -2,6 +2,7 @@ use crate::{services, Error, Result, Ruma};
use ruma::{
api::client::{context::get_context, error::ErrorKind, filter::LazyLoadOptions},
events::StateEventType,
uint,
};
use std::collections::HashSet;
use tracing::error;
@ -70,7 +71,8 @@ pub(crate) async fn get_context_route(
}
// Use limit with maximum 100
let limit = u64::from(body.limit).min(100) as usize;
let half_limit =
usize::try_from(body.limit.min(uint!(100)) / uint!(2)).expect("0-50 should fit in usize");
let base_event = base_event.to_room_event();
@ -78,7 +80,7 @@ pub(crate) async fn get_context_route(
.rooms
.timeline
.pdus_until(sender_user, &room_id, base_token)?
.take(limit / 2)
.take(half_limit)
.filter_map(|r| r.ok()) // Remove buggy events
.filter(|(_, pdu)| {
services()
@ -115,7 +117,7 @@ pub(crate) async fn get_context_route(
.rooms
.timeline
.pdus_after(sender_user, &room_id, base_token)?
.take(limit / 2)
.take(half_limit)
.filter_map(|r| r.ok()) // Remove buggy events
.filter(|(_, pdu)| {
services()