1pub trait Is {
2 fn is(&self, other: &Self) -> bool;
3}
4
5impl Is for f32 {
6 fn is(&self, other: &f32) -> bool {
7 let left_bits: u32 = unsafe { ::std::mem::transmute(*self) };
8 let right_bits: u32 = unsafe { ::std::mem::transmute(*other) };
9 left_bits == right_bits
10 }
11}
12
13impl Is for f64 {
14 fn is(&self, other: &f64) -> bool {
15 let left_bits: u64 = unsafe { ::std::mem::transmute(*self) };
16 let right_bits: u64 = unsafe { ::std::mem::transmute(*other) };
17 left_bits == right_bits
18 }
19}
20
21impl<T: Is> Is for Vec<T> {
22 fn is(&self, other: &Self) -> bool {
23 if self.len() != other.len() {
24 return false;
25 }
26 true
27 }
28}
29
30#[cfg(test)]
31mod test_swf_samples {
32 use super::Is;
33
34 #[test]
35 fn test_f32_is() {
36 assert!(::std::f32::NAN.is(&::std::f32::NAN))
37 }
38}