mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 16:51:01 +00:00
Simplify integer and float functions trait bounds
This commit is contained in:
@ -33,7 +33,7 @@ impl From<OrderedFloat<f64>> for FacetValue {
|
||||
|
||||
impl From<i64> for FacetValue {
|
||||
fn from(integer: i64) -> FacetValue {
|
||||
FacetValue::Number(integer as f64)
|
||||
FacetValue::Number(OrderedFloat(integer as f64))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,16 +13,6 @@ pub fn f64_into_bytes(float: f64) -> Option<[u8; 8]> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn i64_into_bytes(int: i64) -> [u8; 8] {
|
||||
xor_first_bit(int.to_be_bytes())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn i64_from_bytes(bytes: [u8; 8]) -> i64 {
|
||||
i64::from_be_bytes(xor_first_bit(bytes))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn xor_first_bit(mut x: [u8; 8]) -> [u8; 8] {
|
||||
x[0] ^= 0x80;
|
||||
@ -55,15 +45,4 @@ mod tests {
|
||||
let vec: Vec<_> = [a, b, c, d, e].iter().cloned().map(f64_into_bytes).collect();
|
||||
assert!(is_sorted(&vec), "{:?}", vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ordered_i64_bytes() {
|
||||
let a = -10_i64;
|
||||
let b = -0_i64;
|
||||
let c = 1_i64;
|
||||
let d = 43_i64;
|
||||
|
||||
let vec: Vec<_> = [a, b, c, d].iter().cloned().map(i64_into_bytes).collect();
|
||||
assert!(is_sorted(&vec), "{:?}", vec);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user