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

Simplify numeric traits #18640

Closed
brson opened this issue Nov 4, 2014 · 4 comments
Closed

Simplify numeric traits #18640

brson opened this issue Nov 4, 2014 · 4 comments
Assignees
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented.

Comments

@brson
Copy link
Contributor

brson commented Nov 4, 2014

Tracking rust-lang/rfcs#369

@brson brson added the B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. label Nov 4, 2014
@brendanzab
Copy link
Member

I updated the issue description to point to the correct RFC.

@brendanzab
Copy link
Member

By the way, I would love to work on implementing this. I will have a great deal more time on my hands after my last exam tomorrow.

@brendanzab brendanzab self-assigned this Nov 6, 2014
bors added a commit that referenced this issue Nov 14, 2014
This implements a considerable portion of rust-lang/rfcs#369 (tracked in #18640). Some interpretations had to be made in order to get this to work. The breaking changes are listed below:

[breaking-change]

- `core::num::{Num, Unsigned, Primitive}` have been deprecated and their re-exports removed from the `{std, core}::prelude`.
- `core::num::{Zero, One, Bounded}` have been deprecated. Use the static methods on `core::num::{Float, Int}` instead. There is no equivalent to `Zero::is_zero`. Use `(==)` with `{Float, Int}::zero` instead.
- `Signed::abs_sub` has been moved to `std::num::FloatMath`, and is no longer implemented for signed integers.
- `core::num::Signed` has been removed, and its methods have been moved to `core::num::Float` and a new trait, `core::num::SignedInt`. The methods now take the `self` parameter by value.
- `core::num::{Saturating, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv}` have been removed, and their methods moved to `core::num::Int`. Their parameters are now taken by value. This means that
- `std::time::Duration` no longer implements `core::num::{Zero, CheckedAdd, CheckedSub}` instead defining the required methods non-polymorphically.
- `core::num::{zero, one, abs, signum}` have been deprecated. Use their respective methods instead.
- The `core::num::{next_power_of_two, is_power_of_two, checked_next_power_of_two}` functions have been deprecated in favor of methods defined a new trait, `core::num::UnsignedInt`
- `core::iter::{AdditiveIterator, MultiplicativeIterator}` are now only implemented for the built-in numeric types.
- `core::iter::{range, range_inclusive, range_step, range_step_inclusive}` now require `core::num::Int` to be implemented for the type they a re parametrized over.
@ogham
Copy link
Contributor

ogham commented Dec 6, 2014

Is there a reason that the Int and Float traits need to implement Copy? I started writing an interface to the MPFR library, but its types need to implement Drop, which means they can't be copied... it's a shame, because it's otherwise a perfect with for Float and FloatMath.

@alexcrichton
Copy link
Member

This has been implemented for some time now, co closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented.
Projects
None yet
Development

No branches or pull requests

4 participants