mozilla/rust — pull request #8049 by bjz (2013-07-25 22:56:19+00:00)
Title: Divide Num into separate traits

We now have three traits, named according to mathematical conventions.

~~~rust
pub trait Semiring: Eq
+ Add
+ Mul
+ Zero + One {}

pub trait Ring: Semiring
+ Neg
+ Sub {}

pub trait Field: Ring
+ Div
+ Rem {
pub fn recip(&self) -> Self;
}
~~~

You might think this is a tad excessive, but it's useful when you want to define these traits on other mathematical structures such as vectors and quaternions that don't satisfy all the operations required by the old `Num`.

I have also renamed `Orderable` to `OrderedRing`, which is the correct mathematical name. It should strictly really require `TotalOrd`, but we are constrained by the fact that it is not impled by floats.