servo / euclid

Geometry primitives (basic linear algebra) for Rust
Other
462 stars 102 forks source link

Rect::intersection should return None in the presence of NaN. #443

Closed nical closed 4 years ago

nical commented 4 years ago

For example:

    #[test]
    fn test_nan() {
        let r1: Rect<f32> = rect(-2.0, 5.0, 4.0, std::f32::NAN);
        let r2: Rect<f32> = rect(std::f32::NAN, -1.0, 3.0, 10.0);

        assert_eq!(r1.intersection(&r2), None);
    }

gives

thread 'rect::tests::test_nan' panicked at 'assertion failed: `(left == right)`
  left: `Some(Rect(NaNx4.0 at (NaN, 5.0)))`,
 right: `None`', src/rect.rs:914:9