-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax BaseFloat bounds #503
Conversation
This makes the trait more flexible. This contributes to rustgd#496.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you!
I'd love to get a second opinion on this before we proceed.
@brendanzab are you available to look at this?
Looks good to me! |
// Self: approx::AbsDiffEq<Epsilon = <Self as VectorSpace>::Scalar>, | ||
// Self: approx::RelativeEq<Epsilon = <Self as VectorSpace>::Scalar>, | ||
Self: approx::UlpsEq<Epsilon = <Self as VectorSpace>::Scalar>, | ||
Self: MetricSpace<Metric = <Self as VectorSpace>::Scalar> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks so much nicer!
{ | ||
/// Vector dot (or inner) product. | ||
fn dot(self, other: Self) -> Self::Scalar; | ||
|
||
/// Returns `true` if the vector is perpendicular (at right angles) to the | ||
/// other vector. | ||
fn is_perpendicular(self, other: Self) -> bool { | ||
fn is_perpendicular(self, other: Self) -> bool where Self::Scalar: approx::UlpsEq { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
Thank you for reviewing, @brendanzab ! |
Thank you! :) |
This PR makes a step towards finer grained trait bounds (#496)
Here I just relaxed the
BaseFloat
trait bounds intonum_traits::Float
onInnerSpace
,MetricSpace
andis_finite
, and added the required bounds fromapprox
to the functions that need it.This is helpful because it allows the use of common functions like
magnitude
without having to implement theapprox
traits on the number type.