Commit Graph

706 Commits

Author SHA1 Message Date
Jacob Kiesel 28633b7e6d Add clamp function 2017-02-07 09:48:34 -07:00
Josh Stone 817ab00f64 Merge pull request #256 from nwin/add-wrapping-traits
Added traits for wrapping arithmetics.
2017-02-04 21:47:53 -08:00
nwin 58b7da46d2 Added tests. 2017-02-04 10:42:12 +01:00
Josh Stone ba54797d60 Merge pull request #258 from frewsxcv/patch-1
Add doc example for `num_traits::Num::from_str_radix`.
2017-01-31 09:37:30 -08:00
Corey Farwell 19109883de Add doc example for `num_traits::Num::from_str_radix`. 2017-01-30 23:42:27 -05:00
nwin 450c0e2760 Correct typos. 2017-01-26 21:12:27 +01:00
nwin ee9d474243 Ensure compatibility with Rust 1.0.0. 2017-01-22 10:13:50 +01:00
nwin d25f53056d Added traits for wrapping arithmetics.
Added `Wrapping` traits for the most common operations. Similar to the already present `Checked` traits.
2017-01-22 09:45:35 +01:00
Josh Stone 74f1e26f62 macros: bump to 0.1.37 2017-01-11 16:52:06 -08:00
Josh Stone 75372c0639 derive: bump to 0.1.39 2017-01-11 16:51:14 -08:00
Homu bda31b1a33 Auto merge of #252 - est31:master, r=cuviper
macros 1.1 is now stable

Fixes #251. Also includes a patch to get the tests working again.
2017-01-08 08:14:45 +09:00
est31 9aced4066e derive: custom derive is now stable 2017-01-07 23:51:55 +01:00
est31 c742cf9aec derive: use latest compiletest_rs crate
Version 2.2 was not compiling any more: https://github.com/laumann/compiletest-rs/issues/51
2017-01-07 23:51:21 +01:00
Homu a4faeeffc4 Auto merge of #250 - andersk:should_panic, r=cuviper
rational: test_recip_fail: Correct should_panic syntax

Fixes this warning with rustc nightly:

```
warning: attribute must be of the form: `#[should_panic]` or `#[should_panic(expected = "error message")]`
    --> rational/src/lib.rs:1051:7
     |
1051 |     #[should_panic = "== 0"]
     |       ^^^^^^^^^^^^^^^^^^^^^
     |
     = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
```
2017-01-07 06:26:59 +09:00
Anders Kaseorg fd44a86866 rational: test_recip_fail: Correct should_panic syntax
Fixes this warning:

warning: attribute must be of the form: `#[should_panic]` or `#[should_panic(expected = "error message")]`
    --> rational/src/lib.rs:1051:7
     |
1051 |     #[should_panic = "== 0"]
     |       ^^^^^^^^^^^^^^^^^^^^^
     |
     = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-01-06 15:05:01 -05:00
Homu d468177eee Auto merge of #248 - dnsl48:ratio_into_pair, r=cuviper
rational: Into<(T,T)> implementation

Right now it appears impossible to get integers without cloning them. Converting into a pair can be a cheap and easy way to extract the data.
2016-12-10 09:47:59 +09:00
dnsl48 9d7ab663b1 From<(T,T)> implementation 2016-12-10 09:19:02 +13:00
dnsl48 70da35dff5 Into<(T,T)> implementation 2016-12-10 08:39:06 +13:00
Homu 7db32a4ecd Auto merge of #246 - cuviper:complex-eq, r=hauleth
complex: derive Eq

Fixes #245.
2016-12-06 18:48:42 +09:00
Josh Stone 5531031252 complex: derive Eq
Fixes #245.
2016-12-05 23:11:40 -08:00
Homu dc8c8fc3f6 Auto merge of #244 - wictory:master, r=cuviper
Added trait From<T> for Ratio<T> where T: Clone + Integer

Hi!

So I thought that this kind of trait would be useful when one wants to write code which should be generic over different types of numbers.
2016-12-03 07:14:51 +09:00
Homu a63bbc916f Auto merge of #243 - cuviper:intern-macros, r=hauleth
macros: update string interning

None
2016-12-03 07:08:30 +09:00
Wictor Lund 4bdad38eee Added test for trait From<T> for Ratio<T> where T: Clone + Integer. 2016-12-01 22:07:03 +02:00
Wictor Lund de91d5d9e3 Added trait From<T> for Ratio<T> where T: Clone + Integer 2016-12-01 21:38:53 +02:00
Josh Stone be61427d03 derive: bump to 0.1.38 2016-11-28 09:46:18 -08:00
Josh Stone 7ebef5bbe6 macros: update string interning 2016-11-28 09:41:18 -08:00
Josh Stone d7cbdb509c Merge pull request #242 from rust-num/feat/do-not-duplicate-enum-definition
Fix code duplication error

(Overriding a CI failure due to `num-macros`.)
2016-11-28 09:39:36 -08:00
Łukasz Jan Niemier 20243f5baa
fix(num_derive): code duplication error
Fixes #240
2016-11-27 19:31:33 +01:00
Homu 8489f0c388 Auto merge of #239 - bluss:doc-root-url, r=cuviper
Add doc(html_root_url) and other doc attrs to each crate

Also update to use https instead of http. This avoids mixed content
degradation on docs.rs.

The doc root URLs are correct as they are, the URL does not include the
crate name itself.
2016-11-05 02:33:34 +09:00
bluss ff2a350e98 Use the integer32 playground 2016-11-02 19:51:10 +01:00
bluss e4a6956e5a Add doc(html_root_url) and other doc attrs to each crate
Also update to use https instead of http. This avois mixed content
degradation on docs.rs.

The doc root URLs are correct as they are, the URL does not include the
crate name itself.
2016-11-01 02:14:23 +01:00
Homu 938ec63c95 Auto merge of #238 - bluss:fix-mut, r=cuviper
traits: Remove pattern in trait's method signature

This use of `mut` was nonsensical for now, but is proposed to be
disallowed by rustc in the future (as a bugfix).

See rust-lang/rust/pull/37378 for context.
2016-10-25 08:05:35 +09:00
bluss 96e96ef762 Remove pattern in trait's method signature
This use of `mut` was nonsensical for now, but is proposed to be
disallowed by rustc in the future (as a bugfix in Rust).
2016-10-25 00:42:44 +02:00
Josh Stone 8d4b7b3a8d derive: bump to 0.1.37 2016-10-14 20:52:24 -07:00
Homu f2aecb591c Auto merge of #236 - cuviper:proc-macro, r=hauleth
derive: update to proc-macro
2016-10-14 03:59:48 +09:00
Josh Stone 97551ade5b derive: update to proc-macro 2016-10-13 10:31:49 -07:00
Homu b6db1eace9 Auto merge of #235 - matklad:minor-corrections, r=cuviper
Minor, style and comment typo

Just a couple of super minor cosmetic corrections.
2016-10-06 01:30:42 +09:00
Aleksey Kladov ec6ce78458 Minor, style and comment typo 2016-10-05 18:47:30 +03:00
Josh Stone f25a3bd51d 0.1.36 bump for num, traits, macros, and the new derive 2016-09-29 23:31:23 -07:00
Homu 019c136b8c Auto merge of #228 - rust-num:fix/num-macros, r=cuviper
Fix `num-macros` `FromPrimitive` implementation

Current solution follow syntax proposed in rust-lang/rfcs#1681.

Tracking issue rust-lang/rust#35900

Close #227

Code broken after change:

- [ ] https://github.com/kdar/gameboy-rs
- [ ] https://github.com/lemonrock/mbedtls
- [ ] https://github.com/timorantalaiho/kelaa
- [ ] https://github.com/dylanede/cef-rs
- [ ] https://github.com/klutzy/aheui-llvm
- [ ] https://github.com/pcwalton/rust-media
- [ ] https://github.com/PistonDevelopers/hematite_server
2016-09-30 14:58:47 +09:00
Łukasz Jan Niemier b7e64074b2
Add new crate num-derive as an new replacement for num-macro 2016-09-28 13:33:13 +02:00
Łukasz Jan Niemier 0c89b893a9
Add compiletest crate to test against invalid derivations 2016-09-27 11:18:27 +02:00
Łukasz Jan Niemier b038b79900
Merge remote-tracking branch 'origin/master' into fix/num-macros 2016-09-26 20:45:49 +02:00
Łukasz Jan Niemier ada17a1793
Update to syn 0.6.0 2016-09-26 20:32:46 +02:00
Homu 338e4799e6 Auto merge of #231 - AtheMathmo:generic-epsilon, r=hauleth
Implementing epsilon function to retrieve EPSILON constant

Hey!

This PR exposes a new `epsilon` function in the `Float` trait so that users can access the `EPSILON` constant on the float types. I figured as this was such a minimal change it was easier to get a PR in offering the change then write up an issue.

For me this is a valuable addition. When writing linear algebra or other optimization routines with generic floats we often want to check if some stopping criteria is reached, often something like: `(a - b).abs() < eps`. Having access to a standard _small value_ would make this a little easier.
2016-09-23 04:25:29 +09:00
James Lucas 381942eb4f Adding default implementation 2016-09-22 19:56:44 +01:00
James Lucas a64cf66f4c Implementing epsilon function to retrieve EPSILON constant 2016-09-18 14:36:44 -07:00
Łukasz Jan Niemier e9768a0a76
Rebase leftovers 2016-09-18 22:45:53 +02:00
Łukasz Jan Niemier 43cfa25426
Add test case for which `syn` currently fails 2016-09-18 22:43:35 +02:00
Łukasz Jan Niemier 11f8289ed4
Fix `num-macros` `FromPrimitive` implementation
Current solution follow syntax proposed in rust-lang/rfcs#1681.

Tracking issue rust-lang/rust#35900

Close #227
2016-09-18 22:43:34 +02:00