Go to file
Homu f9d36e6d9b Auto merge of #283 - cuviper:more-num, r=cuviper
Add new traits for reference and assignment operators

There are two new "utility" traits covering the basic operators:
`Add`, `Sub`, `Mul`, `Div`, and `Rem`.

- `NumOps<Rhs, Output>`: operators with an arbitrary operand and output.
- `NumAssignOps<Rhs>`: assignment operators with an arbitrary operand.

Then the new collection of numeric traits are:

- `Num`: effectively unchanged, just taking operands by value.
- `NumRef`: `Num` adding reference operands on the right side.
- `RefNum`: `&T` operators, with either `T` or `&T` on the right side.
  - This does not specify `T: Num`, as rust-lang/rust#20671 means that
    could only add a constraint, without implying its presence for use.
- `NumAssign`: `Num` adding assignment operators by value.
- `NumAssignRef`: `NumAssign` adding reference assignment operators.
  - Nothing actually implements this yet!

Acknowledgement: this is roughly based on [@andersk's suggestion](https://github.com/rust-num/num/issues/94#issuecomment-269073071).
2017-05-07 13:40:39 +09:00
benches bigint: allow `Sub` to work in-place on the RHS 2016-07-08 17:34:12 -07:00
bigint num-bigint-0.1.37 2017-03-08 11:14:32 -08:00
ci Bump rustc to 1.8 and revamp all CI 2017-02-09 16:09:48 -08:00
complex num-complex-0.1.37 2017-04-09 06:18:09 -07:00
derive Add licenses to subcrates 2017-02-26 13:39:23 -08:00
doc Update repo and doc links 2015-11-12 18:40:13 -08:00
integer num-integer-0.1.34 2017-04-09 06:22:05 -07:00
iter Add licenses to subcrates 2017-02-26 13:39:23 -08:00
macros Add licenses to subcrates 2017-02-26 13:39:23 -08:00
rational rational: Implement approximation from floats and FromPrimitive for various types 2017-05-02 02:28:27 +03:00
src Made requested changes. 2017-02-07 13:02:32 -07:00
traits Implement RefNum more generically 2017-05-06 21:35:38 -07:00
.gitignore Update num-macros to Rust master 2015-05-14 10:19:47 -07:00
.travis.yml Bump rustc to 1.8 and revamp all CI 2017-02-09 16:09:48 -08:00
Cargo.toml Bump versions in the num collection 2017-02-26 14:18:33 -08:00
LICENSE-APACHE Initial seeding from rust repo 2014-09-16 10:35:35 -07:00
LICENSE-MIT Initial seeding from rust repo 2014-09-16 10:35:35 -07:00
README.md add missing '`' in README.md 2017-05-03 14:41:43 +08:00

README.md

num

A collection of numeric types and traits for Rust.

This includes new types for big integers, rationals, and complex numbers, new traits for generic programming on numeric properties like Integer, and generic range iterators.

Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
num = "0.1"

and this to your crate root:

extern crate num;

Compatibility

Most of the num crates are tested for rustc 1.8 and greater. The exceptions are num-derive which requires at least rustc 1.15, and the deprecated num-macros which requires nightly rustc.