From 6e540bc6c18b2eb2eb2daba36fa58a9f975e7d5a Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 28 Jul 2026 16:51:07 +0200 Subject: [PATCH] chore(search): Use a const expression for `MAX_MILLISECONDS`. --- crates/matrix-sdk-search/src/index/mod.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/matrix-sdk-search/src/index/mod.rs b/crates/matrix-sdk-search/src/index/mod.rs index bed39c0cb..a85d571de 100644 --- a/crates/matrix-sdk-search/src/index/mod.rs +++ b/crates/matrix-sdk-search/src/index/mod.rs @@ -62,9 +62,7 @@ pub struct IndexableEvent { /// Maximum value for the timestamp to not overflow when converted to /// nanoseconds by Tantivy. See [`IndexableEvent::new`] to learn more. -/// -/// This is the value of `i64::MAX / 1_000_000` but folded as a `u64`. -const MAX_MILLISECONDS: u64 = 9_223_372_036_854; +const MAX_MILLISECONDS: u64 = (i64::MAX / 1_000_000).cast_unsigned(); impl IndexableEvent { /// Create a new [`IndexableEvent`]. @@ -493,12 +491,6 @@ mod tests { index.execute(RoomIndexOperation::Edit(event_id.to_owned(), to_indexable(&new))) } - /// Ensure `MAX_MILLISECONDS` is correctly set to `i64::MAX / 1_000_000`. - #[test] - fn test_max_milliseconds() { - assert_eq!(u64::try_from(i64::MAX / 1_000_000).unwrap(), MAX_MILLISECONDS); - } - #[test] fn test_add_event() { let room_id = room_id!("!room_id:localhost");