f9d36e6d9b
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). |
||
---|---|---|
benches | ||
bigint | ||
ci | ||
complex | ||
derive | ||
doc | ||
integer | ||
iter | ||
macros | ||
rational | ||
src | ||
traits | ||
.gitignore | ||
.travis.yml | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |
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.
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.