Josh Stone
f0ed42b3bc
Test edge cases of ToPrimitive with ints
2018-03-11 01:37:27 -08:00
Josh Stone
50868c60d2
Refactor to_primitive_int/uint macros
2018-03-11 01:37:00 -08:00
Josh Stone
6d7bbb1b53
Mask debug prints no-std mode
2018-03-11 01:36:17 -08:00
Josh Stone
d195eafbe2
Simplify the to_primitive_float macros
2018-03-10 23:33:47 -08:00
Josh Stone
f6dc4d29a4
Add thorough tests of float to int edge cases
2018-03-10 23:05:02 -08:00
Josh Stone
b025c273c7
Rewrite range checks in float ToPrimitive macros
2018-03-10 23:01:30 -08:00
Dan Barella
8e27c7327d
Rename some tests.
2018-03-10 15:14:23 -08:00
Dan Barella
aab7098acd
Reformat macros.
2018-03-10 15:14:23 -08:00
Alexander Popiak
c32cb5c65b
Patch in apopiak@'s changes from github.com/rust-num/num/pull/135/.
2018-03-10 15:14:23 -08:00
Dan Barella
ab8fda7654
Change assert form.
2018-03-10 15:14:23 -08:00
Dan Barella
ecb0816c83
Remove an unneeded assert.
2018-03-10 15:14:23 -08:00
Dan Barella
3534a89858
Don't use assert_ne!
...
`num` is tested against `rust 1.8.0`, which doesn't include
`assert_ne!` -- so we use a plain ol' `assert` instead.
2018-03-10 15:14:23 -08:00
Dan Barella
f99aa0e181
Check overflow when casting floats to integers.
...
This change adds some new macro rules used when converting from floats
to integers. There are two macro rule variants, one for signed ints, one
for unsigned ints.
Among other things, this change specifically addresses the overflow case
documented in https://github.com/rust-num/num-traits/issues/12
2018-03-10 15:14:23 -08:00
Josh Stone
ac503261ca
Forward FloatCore to inherent methods when possible
2018-02-27 16:33:04 -08:00
Vinzent Steinberg
efad5329b4
Rename CoreFloat to FloatCore
2018-02-07 12:34:14 +01:00
Vinzent Steinberg
8a7f383eb1
Implement CoreFloat trait
...
This is a subset of the `Float` trait, but works with `no_std`.
Some code was simplified by using `CoreFloat`.
2018-02-02 19:48:25 +01:00
Josh Stone
e6bb97b3ac
Make `Float` and `Real` depend on the `std` feature
...
We don't have implementations for many of the methods in `no_std`. It's
hostile to external implementors if some trait methods are conditional
on a feature, as that feature could be added by anyone in a dependency
tree. Instead, let's just live without these traits for now.
2018-01-31 15:56:06 -08:00
Vinzent Steinberg
a843027b56
Re-introduce the std feature
...
This is a port of @vks's rust-num/num#296 , but without the feature-
toggled changes to `Float`.
2018-01-31 15:42:55 -08:00
Eduardo Pinho
31218add95
Include note for implementers of AsPrimitive
2018-01-14 21:23:19 +00:00
Eduardo Pinho
af693fef48
Add safety notice in AsPrimitive docs
2017-12-21 21:03:25 +00:00
Eduardo Pinho
773a222237
Add conversions from `bool` in `AsPrimitive`
2017-12-20 21:41:45 +00:00
Eduardo Pinho
741e1f4e09
Add AsPrimitive trait, impls and tests
2017-12-20 00:05:36 +00:00
Josh Stone
42a610d323
Move num-traits to its own repo
...
All the prior `num` history is kept, so old `num-traits` tags are still
valid, but future development here will be just for `num-traits`.
2017-12-18 17:35:41 -08:00