2018-09-20 20:23:31 +08:00
|
|
|
use approx::AbsDiffEq;
|
2021-08-08 18:59:40 +08:00
|
|
|
use num::{Bounded, Signed};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
use na::Scalar;
|
2021-08-08 19:05:13 +08:00
|
|
|
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, RealField};
|
2020-04-05 23:13:34 +08:00
|
|
|
use std::cmp::PartialOrd;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// A number that can either be an integer or a float.
|
2018-10-22 04:11:27 +08:00
|
|
|
pub trait Number:
|
2020-04-05 23:13:34 +08:00
|
|
|
Scalar
|
|
|
|
+ Copy
|
|
|
|
+ PartialOrd
|
|
|
|
+ ClosedAdd
|
|
|
|
+ ClosedSub
|
|
|
|
+ ClosedMul
|
|
|
|
+ AbsDiffEq<Epsilon = Self>
|
|
|
|
+ Signed
|
|
|
|
+ Bounded
|
2018-10-22 04:11:27 +08:00
|
|
|
{
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2020-03-21 19:16:46 +08:00
|
|
|
impl<
|
|
|
|
T: Scalar
|
|
|
|
+ Copy
|
2020-04-05 23:13:34 +08:00
|
|
|
+ PartialOrd
|
|
|
|
+ ClosedAdd
|
|
|
|
+ ClosedSub
|
|
|
|
+ ClosedMul
|
2020-03-21 19:16:46 +08:00
|
|
|
+ AbsDiffEq<Epsilon = Self>
|
|
|
|
+ Signed
|
2021-08-08 19:05:13 +08:00
|
|
|
+ Bounded,
|
2020-03-21 19:16:46 +08:00
|
|
|
> Number for T
|
|
|
|
{
|
|
|
|
}
|
2021-08-08 18:59:40 +08:00
|
|
|
|
|
|
|
/// A number that can be any float type.
|
|
|
|
pub trait RealNumber: Number + RealField {}
|
|
|
|
|
|
|
|
impl<T: Number + RealField> RealNumber for T {}
|