mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-08-02 10:57:33 -04:00
chore(search): Use a const expression for MAX_MILLISECONDS.
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user