chore(search): Use a const expression for MAX_MILLISECONDS.

This commit is contained in:
Ivan Enderlin
2026-07-28 16:51:07 +02:00
parent 58dbb91bec
commit 6e540bc6c1

View File

@@ -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");