Floating point numbers don't have a total ordering (all of these are
false: NaN < NaN, NaN == NaN, NaN > NaN).
Use the floating-point specific method, `self.a.max(self.b)`.
Huon
On 05/04/14 19:30, Rémi Fontan wrote:
Hi,
when compiling following code with rust 0.10 I get following error:
use std::cmp;
struct vec2d { a:f32, b:f32 }
impl vec2d {
pub fn max(&self) -> f32 {
cmp::max(self.a, self.b)
}
}
test.rs:6:9: 6:17 error: failed to find an implementation of trait
std::cmp::TotalOrd for f32
test.rs:6 <http://test.rs:6> cmp::max(self.a, self.b)
^~~~~~~~
make: *** [test-test] Error 101
have I missed something?
cheers,
Rémi
--
Rémi Fontan : remifon...@yahoo.fr <mailto:remifon...@yahoo.fr>
mobile: +64 21 855 351
93 Otaki Street, Miramar 6022
Wellington, New Zealand
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev