Skip to content

Commit 59cef2c

Browse files
committed
bit comparison of f32, f64
1 parent fb10fa3 commit 59cef2c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

diffus/src/same.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ macro_rules! same_for_eq {
2424

2525
same_for_eq! { u8, u16, u32, u64, i8, i16, i32, i64, char, str, String }
2626

27+
macro_rules! same_for_float {
28+
($($typ:ty),*) => {
29+
$(
30+
impl Same for $typ {
31+
fn same(&self, other: &Self) -> bool {
32+
self.to_ne_bytes() == other.to_ne_bytes()
33+
}
34+
}
35+
)*
36+
}
37+
}
38+
39+
same_for_float! { f32, f64 }
40+
2741
#[cfg(feature = "snake_case-impl")]
2842
same_for_eq! { snake_case::SnakeCase }
2943

0 commit comments

Comments
 (0)