From c6bc62c95faa9f96074e9eecb24aa5296a543f81 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Mon, 24 Sep 2018 05:58:58 +0200 Subject: [PATCH] For matrices, return the actual result of partial_clamp instead of None. Fix #401 --- src/base/matrix.rs | 2 +- tests/core/matrix.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 579848d2..6d99acbf 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -909,7 +909,7 @@ where } } - None + first_ord } #[inline] diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 3c6f8e99..e0a552ee 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -706,6 +706,16 @@ fn set_row_column() { assert_eq!(expected2, computed); } +#[test] +fn partial_clamp() { + // NOTE: from #401. + let n = Vector2::new(1.5, 0.0); + let min = Vector2::new(-75.0, -0.0); + let max = Vector2::new(75.0, 0.0); + let inter = na::partial_clamp(&n, &min, &max); + assert_eq!(*inter.unwrap(), n); +} + #[cfg(feature = "arbitrary")] mod transposition_tests { use super::*;