Skip to content

Commit 93be5db

Browse files
committed
Merge #23
23: Add RealNum trait for real data types (Float, but without floating-point specific features) r=cuviper a=yoanlcq This is supposed to fix [#19](#19); I assumed going ahead would be better than bumping the thread. In any case, I understand that it is a quite significant addition and won't mind too much if it doesn't make it. This adds a new `RealNum` trait, along with a universal impl `impl<T: Float> RealNum for T { ... }`. Therefore, this shouldn't be a breaking change, except in places where both traits are imported (which obviously only happened in a few places in this crate). The intent is that generic code may prefer to use `RealNum` instead of `Float` when floating-point isn't a requirement. In the future (next major version ?), I guess `Float` could be made to only provide floating-point-specific features on top of `RealNum`. Most of the code+doc was copy-pasted from `Float`, but the doc comments should be up-to-date with the situation; `Float` only makes an appearance when talking about NaN and infinity. Issues I've seen : - `RealNum` might not be the name we want; - I've mentioned that `sqrt()` is allowed to panic if the input is negative and has no meaningful NaN representation; - Should we do that too for e.g `log()` ? Like `sqrt()`, it's supposed to return Nan when `x < 0`. Thanks for your time. :)
2 parents aa7c15e + 1e892e2 commit 93be5db

File tree

2 files changed

+926
-0
lines changed

2 files changed

+926
-0
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::fmt;
1919

2020
pub use bounds::Bounded;
2121
pub use float::{Float, FloatConst};
22+
// pub use real::Real; // NOTE: Don't do this, it breaks `use num_traits::*;`.
2223
pub use identities::{Zero, One, zero, one};
2324
pub use ops::checked::*;
2425
pub use ops::wrapping::*;
@@ -33,6 +34,7 @@ pub mod sign;
3334
pub mod ops;
3435
pub mod bounds;
3536
pub mod float;
37+
pub mod real;
3638
pub mod cast;
3739
pub mod int;
3840
pub mod pow;

0 commit comments

Comments
 (0)