On Fri, Jun 14, 2013 at 7:11 PM, Rémi Fontan <[email protected]> wrote: > Hi, > > I have difficulties understanding how to use functions from the cmp module. > With following example, I get errors when trying to compile it. There is > something obvious I must not understand. > > > errors: > rustc test.rs -o test-test --test > test.rs:15:12: 15:20 error: unresolved name > test.rs:15 cmp::max(self.x, self.y) > ^~~~~~~~ > test.rs:15:12: 15:20 error: use of undeclared module `cmp` > test.rs:15 cmp::max(self.x, self.y) > ^~~~~~~~ > test.rs:15:12: 15:20 error: unresolved name `cmp::max`. > test.rs:15 cmp::max(self.x, self.y) > ^~~~~~~~ > error: aborting due to 3 previous errors > make: *** [test-test] Error 101 > > > > code: > extern mod std; > use std::cmp; > > use math::*; > > pub mod math { > > #[deriving(Eq, Clone)] > struct Vec2x<T> { x:T, y:T } > > impl<T:Real> Vec2x<T> { > pub fn new(a:T, b:T) -> Vec2x<T> { Vec2x{x:a, y:b} } > > pub fn max(&self) -> T { > cmp::max(self.x, self.y) > } > } > } > > > #[test] > fn test_Vec2x() { > let v = Vec2x::new(1f,2f); > } > > > > Would you be able to explain me? > > I'm using the latest rust version from git: brew install rust --HEAD > > cheers, > > Remi > > > > -- > Rémi Fontan : [email protected] > mobile: +64 21 855 351 > 93 Otaki Street, Miramar 6022 > Wellington, New Zealand
The top-level `use std::cmp` isn't visible from `mod math`. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
