diff --git a/src/bounded.rs b/src/bounded.rs index a3cdfbb..2df6ce7 100644 --- a/src/bounded.rs +++ b/src/bounded.rs @@ -60,10 +60,6 @@ mod tests #[test] fn $func_name() { - use bounded::Bounded; - - - assert_eq!($T::MIN, $minVal); assert_eq!($T::MAX, $maxVal); } diff --git a/src/constants.rs b/src/constants.rs index 52a68ab..a4731a0 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -57,6 +57,7 @@ pub trait Constants const INVERSE_SQRT_3: Self; /// The mathematical constant [E][1]. Also known as [Euler's number][1]. + /// /// [1]: https://en.wikipedia.org/wiki/E_(mathematical_constant) /// ///``` @@ -130,6 +131,7 @@ pub trait Constants const TWO_PI: Self; /// [PI][1]. The ratio of a circles circumference to its diameter. + /// /// [1]: https://en.wikipedia.org/wiki/Pi /// ///``` diff --git a/src/lib.rs b/src/lib.rs index ecdd716..49e7f40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ pub mod quaternion; pub use self::bounded::Bounded; pub use self::zero::Zero; pub use self::one::One; -pub use self::number::Number; +pub use self::number::{Number, FromNumber}; pub use self::whole::Whole; pub use self::integer::Integer; pub use self::real::Real; diff --git a/src/matrix.rs b/src/matrix.rs index 79e9eac..f11fe00 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -1,8 +1,6 @@ //! This module defines the 2x2, 3x3, and 4x4 Matrix structures. -use std::ops::{Add, Sub, Mul, Div, Rem, Neg}; +//use std::ops::{Add, Sub, Mul, Div, Rem, Neg}; -use crate::zero::Zero; -use crate::one::One; use crate::number::Number; use crate::vector::{Vector, Vector2, Vector3, Vector4}; diff --git a/src/one.rs b/src/one.rs index 7694e8e..9d543ab 100644 --- a/src/one.rs +++ b/src/one.rs @@ -7,7 +7,7 @@ pub trait One: Sized + Mul /// /// # Laws /// - /// ```{.text} + /// ```text /// a * 1 = a ∀ a ∈ Self /// 1 * a = a ∀ a ∈ Self /// ``` diff --git a/src/quaternion.rs b/src/quaternion.rs index 0b20453..768ef40 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -8,10 +8,8 @@ use std::ops::{Add, Sub, Mul, Div, Neg}; use crate::zero::Zero; use crate::one::One; -use crate::real::Real; -use crate::trig::Radian; use crate::trig::Trig; -use crate::vector::{Vector, EuclideanVector, Vector3}; +use crate::vector::{EuclideanVector, Vector3}; diff --git a/src/real.rs b/src/real.rs index a712748..38aebc8 100644 --- a/src/real.rs +++ b/src/real.rs @@ -159,22 +159,18 @@ pub trait Real : Number + Constants + Neg /// use std::{f32, f64}; /// use sigils::Real; /// - /// let nan32: f32 = f32::NAN; /// let f_val32 = 7.0f32; /// let g_val32 = -7.0f32; /// - /// let nan64: f64 = f64::NAN; /// let f_val64 = 7.0f64; /// let g_val64 = -7.0f64; /// /// // Requires both tests to determine if is `NaN` /// assert!(!f_val32.is_sign_negative()); /// assert!(g_val32.is_sign_negative()); - /// assert!(!nan32.is_sign_positive() && !nan32.is_sign_negative()); /// /// assert!(!f_val64.is_sign_negative()); /// assert!(g_val64.is_sign_negative()); - /// assert!(!nan64.is_sign_positive() && !nan64.is_sign_negative()); /// ``` fn is_sign_negative(self) -> bool; @@ -185,22 +181,18 @@ pub trait Real : Number + Constants + Neg /// use std::{f32, f64}; /// use sigils::Real; /// - /// let nan32: f32 = f32::NAN; /// let f_val32 = 7.0f32; /// let g_val32 = -7.0f32; /// - /// let nan64: f64 = f64::NAN; /// let f_val64 = 7.0f64; /// let g_val64 = -7.0f64; /// /// // Requires both tests to determine if is `NaN` /// assert!(f_val32.is_sign_positive()); /// assert!(!g_val32.is_sign_positive()); - /// assert!(!nan32.is_sign_positive() && !nan32.is_sign_negative()); /// /// assert!(f_val64.is_sign_positive()); /// assert!(!g_val64.is_sign_positive()); - /// assert!(!nan64.is_sign_positive() && !nan64.is_sign_negative()); /// ``` fn is_sign_positive(self) -> bool; @@ -228,8 +220,6 @@ pub trait Real : Number + Constants + Neg /// ``` fn get_signum(self) -> Self; - /* TODO: Reimplement this when the error for 'use core::num::Float;' - goes away. /// Returns the floating point category of the number. /// If only one property is going to be tested, it is /// generally faster to use the specific predicate instead. @@ -252,9 +242,7 @@ pub trait Real : Number + Constants + Neg /// assert_eq!(inf64.get_category(), FpCategory::Infinite); /// ``` fn get_category(self) -> FpCategory; - */ - // TODO: Fix/check this example. /// Returns the mantissa, base 2 exponent, and sign as /// integers, respectively. The original number can be /// recovered by `sign * mantissa * 2 ^ exponent`. @@ -265,7 +253,7 @@ pub trait Real : Number + Constants + Neg /// let num = 2.0f32; /// /// // (8388608, -22, 1) - /// let (mantissa, exponent, sign) = Real::integer_decode(num); + /// let (mantissa, exponent, sign) = Real::get_integer_decode(num); /// let sign_f = sign as f32; /// let mantissa_f = mantissa as f32; /// let exponent_f = num.powf(exponent as f32); @@ -701,13 +689,10 @@ impl Real for f32 } } - /* TODO: Reimplement this when the error for 'use core::num::Float;' - goes away. fn get_category(self) -> FpCategory { self.classify() } - */ fn get_integer_decode(self) -> (u64, i16, i8) { @@ -963,13 +948,10 @@ impl Real for f64 } } - /* TODO: Reimplement this when the error for 'use core::num::Float;' - goes away. fn get_category(self) -> FpCategory { self.classify() } - */ fn get_integer_decode(self) -> (u64, i16, i8) { diff --git a/src/vector.rs b/src/vector.rs index 4810566..4ccc9c4 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -8,7 +8,6 @@ use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; use crate::zero::Zero; use crate::one::One; use crate::number::Number; -use crate::real::Real; use crate::trig::Radian; use crate::trig::Trig; diff --git a/src/zero.rs b/src/zero.rs index 6ff510e..34ffa95 100644 --- a/src/zero.rs +++ b/src/zero.rs @@ -7,7 +7,7 @@ pub trait Zero: Sized + Add /// /// # Laws /// - /// ```{.text} + /// ```text /// a + 0 = a ∀ a ∈ Self /// 0 + a = a ∀ a ∈ Self /// ```