Confusion about using trait impls defined in cgmath

I'm still in the learning phase with Rust, so apologies if this is a simple one.

I'm using the cgmath crate in a smallish game project (using wgpu-rs, and it's a hoot); Doing some geometry work I wrote some test coverage and needed an approximate comparison for point structs with floating point members. Normally I'd use the abs method on f32 to do "fuzzy" comparisons, but looking into the lib, I saw that cgmath offers a trait impl for approx::RelativeEq

According to approx doc this does exactly what I want: Cool! I figured I could just add the right use directive and be good to go. But for the life of me I can't figure out how to bring this trait into scope and use it.

Other traits in cgmath can be brought in easily:

use cgmath::{Point2,MetricSpace};

And now I can use the distance2 method on Point2. Just as I'd expect. But how do I bring the trait from approx into scope? Do I have to add approx to my own Cargo.toml just to bring its traits into scope?

I've tried bringing in cgmath's approx via use cgmath::approx::RelativeEq; but it errors with "crate approx is private" which makes sense.

Apologies if this is a dumb question, but having grown comfy with the language with a few toy projects, I'm now in the process of building things with Rust, and learning the nuances of the dependency system.

According to the crate documentation, RelativeEq is available from the crate root, i.e. with use cgmath::RelativeEq. In the library source code it is provided with pub use approx::*.

I guess that's the obvious thing I managed not to try. It works! Thanks,

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.