Skip to content
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

Merged
merged 3 commits into from
May 23, 2020
Merged

Relax BaseFloat bounds #503

merged 3 commits into from
May 23, 2020

Conversation

elrnv
Copy link
Contributor

@elrnv elrnv commented May 21, 2020

This PR makes a step towards finer grained trait bounds (#496)

Here I just relaxed the BaseFloat trait bounds into num_traits::Float on InnerSpace, MetricSpace and is_finite, and added the required bounds from approx to the functions that need it.

This is helpful because it allows the use of common functions like magnitude without having to implement the approx traits on the number type.

Copy link
Collaborator

@kvark kvark left a 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?

src/structure.rs Outdated Show resolved Hide resolved
@brendanzab
Copy link
Collaborator

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>
Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

@kvark
Copy link
Collaborator

kvark commented May 23, 2020

Thank you for reviewing, @brendanzab !

@kvark kvark merged commit 9dcd9fc into rustgd:master May 23, 2020
@elrnv
Copy link
Contributor Author

elrnv commented May 23, 2020

Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants