[#1] Fixed up unused imports, docs, and tests.

This commit is contained in:
Myrddin Dundragon 2025-03-10 13:04:37 -04:00
parent 273a7c1699
commit 59b1e2eea1
9 changed files with 8 additions and 33 deletions

View File

@ -60,10 +60,6 @@ mod tests
#[test]
fn $func_name()
{
use bounded::Bounded;
assert_eq!($T::MIN, $minVal);
assert_eq!($T::MAX, $maxVal);
}

View File

@ -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
///
///```

View File

@ -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;

View File

@ -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};

View File

@ -7,7 +7,7 @@ pub trait One: Sized + Mul<Self, Output=Self>
///
/// # Laws
///
/// ```{.text}
/// ```text
/// a * 1 = a ∀ a ∈ Self
/// 1 * a = a ∀ a ∈ Self
/// ```

View File

@ -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};

View File

@ -159,22 +159,18 @@ pub trait Real : Number + Constants + Neg<Output=Self>
/// 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<Output=Self>
/// 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<Output=Self>
/// ```
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<Output=Self>
/// 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<Output=Self>
/// 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)
{

View File

@ -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;

View File

@ -7,7 +7,7 @@ pub trait Zero: Sized + Add<Self, Output=Self>
///
/// # Laws
///
/// ```{.text}
/// ```text
/// a + 0 = a ∀ a ∈ Self
/// 0 + a = a ∀ a ∈ Self
/// ```