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

Implement to_radians and to_degrees for Float #211

Closed
frewsxcv opened this issue Jul 22, 2016 · 6 comments
Closed

Implement to_radians and to_degrees for Float #211

frewsxcv opened this issue Jul 22, 2016 · 6 comments

Comments

@frewsxcv
Copy link
Contributor

https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.to_degrees

https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.to_radians

To better mirror what's offered in the standard library, it'd be nice if these methods were available for any Float.

@cuviper
Copy link
Member

cuviper commented Jul 22, 2016

Curious that those are missing. Is there anything else in f32 and f64 that we lack?

It's a breaking change to add methods to a trait, unless you provide a default implementation. Is there a way to generically write these? Then f32 and f64 can override with their native versions, of course.

@frewsxcv
Copy link
Contributor Author

Relevant discussion in georust/geo#48 by the way. Feel free to take any of my code I wrote.

@cuviper
Copy link
Member

cuviper commented Jul 23, 2016

Ugh. Rust 1.0 had these stable for f64, but not until 1.7 for f32 . (rust-lang/rust#30672)

@frewsxcv
Copy link
Contributor Author

What would be the next step forward for this? In what way would it be a breaking change? Do you think it'd be possible to write a default implementation?

@cuviper
Copy link
Member

cuviper commented Jul 23, 2016

It's a little annoying since their Float implementations are shared, but I can code it openly for now. And I think I've got a way to write a default too, so it's not a breaking change.

cuviper added a commit to cuviper/num that referenced this issue Jul 23, 2016
To avoid a breaking change, these have crude default implementations as
well as better implementations for `f32` and `f64` in particular.  They
don't use the inherent methods though, because `f32` didn't stabilize
those until Rust 1.7.

Fixes rust-num#211
@cuviper
Copy link
Member

cuviper commented Jul 23, 2016

Please let me know if #212 looks ok to you.

@homu homu closed this as completed in #212 Jul 24, 2016
homu added a commit that referenced this issue Jul 24, 2016
traits: add `to_degrees` and `to_radians` on `Float`

To avoid a breaking change, these have crude default implementations as
well as better implementations for `f32` and `f64` in particular.  They
don't use the inherent methods though, because `f32` didn't stabilize
those until Rust 1.7.

Fixes #211
remexre pushed a commit to remexre/num that referenced this issue Jun 1, 2017
Implement indexing into Value
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

No branches or pull requests

2 participants