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
https://github.com/rustgd/cgmath/blob/master/src/point.rs#L207
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.