diff --git a/src/lib.rs b/src/lib.rs index 317ef89e..c2a6ac9c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,8 +147,8 @@ pub use traits::{ Norm, Orig, Outer, - PartialOrd, - PartialOrdering, + POrd, + POrdering, PntAsVec, RMul, Rotate, Rotation, RotationMatrix, RotationWithTranslation, @@ -228,7 +228,7 @@ pub mod overload { /// Change the input value to ensure it is on the range `[min, max]`. #[inline(always)] -pub fn clamp(val: T, min: T, max: T) -> T { +pub fn clamp(val: T, min: T, max: T) -> T { if val > min { if val < max { val @@ -256,63 +256,63 @@ pub fn min(a: T, b: T) -> T { /// Returns the infimum of `a` and `b`. #[inline(always)] -pub fn inf(a: &T, b: &T) -> T { - PartialOrd::inf(a, b) +pub fn inf(a: &T, b: &T) -> T { + POrd::inf(a, b) } /// Returns the supremum of `a` and `b`. #[inline(always)] -pub fn sup(a: &T, b: &T) -> T { - PartialOrd::sup(a, b) +pub fn sup(a: &T, b: &T) -> T { + POrd::sup(a, b) } /// Compare `a` and `b` using a partial ordering relation. #[inline(always)] -pub fn partial_cmp(a: &T, b: &T) -> PartialOrdering { - PartialOrd::partial_cmp(a, b) +pub fn partial_cmp(a: &T, b: &T) -> POrdering { + POrd::partial_cmp(a, b) } /// Returns `true` iff `a` and `b` are comparable and `a < b`. #[inline(always)] -pub fn partial_lt(a: &T, b: &T) -> bool { - PartialOrd::partial_lt(a, b) +pub fn partial_lt(a: &T, b: &T) -> bool { + POrd::partial_lt(a, b) } /// Returns `true` iff `a` and `b` are comparable and `a <= b`. #[inline(always)] -pub fn partial_le(a: &T, b: &T) -> bool { - PartialOrd::partial_le(a, b) +pub fn partial_le(a: &T, b: &T) -> bool { + POrd::partial_le(a, b) } /// Returns `true` iff `a` and `b` are comparable and `a > b`. #[inline(always)] -pub fn partial_gt(a: &T, b: &T) -> bool { - PartialOrd::partial_gt(a, b) +pub fn partial_gt(a: &T, b: &T) -> bool { + POrd::partial_gt(a, b) } /// Returns `true` iff `a` and `b` are comparable and `a >= b`. #[inline(always)] -pub fn partial_ge(a: &T, b: &T) -> bool { - PartialOrd::partial_ge(a, b) +pub fn partial_ge(a: &T, b: &T) -> bool { + POrd::partial_ge(a, b) } /// Return the minimum of `a` and `b` if they are comparable. #[inline(always)] -pub fn partial_min<'a, T: PartialOrd>(a: &'a T, b: &'a T) -> Option<&'a T> { - PartialOrd::partial_min(a, b) +pub fn partial_min<'a, T: POrd>(a: &'a T, b: &'a T) -> Option<&'a T> { + POrd::partial_min(a, b) } /// Return the maximum of `a` and `b` if they are comparable. #[inline(always)] -pub fn partial_max<'a, T: PartialOrd>(a: &'a T, b: &'a T) -> Option<&'a T> { - PartialOrd::partial_max(a, b) +pub fn partial_max<'a, T: POrd>(a: &'a T, b: &'a T) -> Option<&'a T> { + POrd::partial_max(a, b) } /// Clamp `value` between `min` and `max`. Returns `None` if `value` is not comparable to /// `min` or `max`. #[inline(always)] -pub fn partial_clamp<'a, T: PartialOrd>(value: &'a T, min: &'a T, max: &'a T) -> Option<&'a T> { - PartialOrd::partial_clamp(value, min, max) +pub fn partial_clamp<'a, T: POrd>(value: &'a T, min: &'a T, max: &'a T) -> Option<&'a T> { + POrd::partial_clamp(value, min, max) } // diff --git a/src/structs/pnt.rs b/src/structs/pnt.rs index a980d70f..7e0b1f3c 100644 --- a/src/structs/pnt.rs +++ b/src/structs/pnt.rs @@ -6,7 +6,7 @@ use std::mem; use std::num::{Zero, One, Bounded}; use std::slice::{Items, MutItems}; use std::iter::{Iterator, FromIterator}; -use traits::operations::{ApproxEq, PartialOrd, PartialOrdering, PartialLess, PartialEqual, +use traits::operations::{ApproxEq, POrd, POrdering, PartialLess, PartialEqual, PartialGreater, NotComparable, Axpy}; use traits::structure::{Cast, Dim, Indexable, Iterable, IterableMut, PntAsVec}; use traits::geometry::{Orig, FromHomogeneous, ToHomogeneous}; diff --git a/src/structs/quat.rs b/src/structs/quat.rs index 266df2a6..268d4674 100644 --- a/src/structs/quat.rs +++ b/src/structs/quat.rs @@ -8,7 +8,7 @@ use std::num; use std::rand::{Rand, Rng}; use std::slice::{Items, MutItems}; use structs::{Vec3, Pnt3, Rot3, Mat3, Vec3MulRhs, Pnt3MulRhs}; -use traits::operations::{ApproxEq, Inv, PartialOrd, PartialOrdering, NotComparable, PartialLess, +use traits::operations::{ApproxEq, Inv, POrd, POrdering, NotComparable, PartialLess, PartialGreater, PartialEqual, Axpy}; use traits::structure::{Cast, Indexable, Iterable, IterableMut, Dim}; use traits::geometry::{Norm, Cross, Rotation, Rotate, Transform}; diff --git a/src/structs/vec.rs b/src/structs/vec.rs index 45c7dc29..995fa9fa 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -6,7 +6,7 @@ use std::mem; use std::num::{Zero, One, Float, Bounded}; use std::slice::{Items, MutItems}; use std::iter::{Iterator, FromIterator}; -use traits::operations::{ApproxEq, PartialOrd, PartialOrdering, PartialLess, PartialEqual, +use traits::operations::{ApproxEq, POrd, POrdering, PartialLess, PartialEqual, PartialGreater, NotComparable, Axpy}; use traits::geometry::{Transform, Rotate, FromHomogeneous, ToHomogeneous, Dot, Norm, Translation, Translate}; diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index 5145723b..0947cd3b 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -58,7 +58,7 @@ macro_rules! at_fast_impl( // However, f32/f64 does not implement Ord… macro_rules! ord_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl PartialOrd for $t { + impl POrd for $t { #[inline] fn inf(a: &$t, b: &$t) -> $t { $t::new(a.$comp0.min(b.$comp0.clone()) @@ -73,7 +73,7 @@ macro_rules! ord_impl( #[inline] #[allow(unused_mut)] // otherwise there will be a warning for is_eq or Vec1. - fn partial_cmp(a: &$t, b: &$t) -> PartialOrdering { + fn partial_cmp(a: &$t, b: &$t) -> POrdering { let is_lt = a.$comp0 < b.$comp0; let mut is_eq = a.$comp0 == b.$comp0; diff --git a/src/traits/mod.rs b/src/traits/mod.rs index eb7e8f8b..7d1c53a3 100644 --- a/src/traits/mod.rs +++ b/src/traits/mod.rs @@ -8,9 +8,9 @@ pub use self::structure::{FloatVec, FloatVecExt, FloatPnt, FloatPntExt, Basis, C Indexable, Iterable, IterableMut, Mat, Row, AnyVec, AnyVecExt, AnyPnt, AnyPntExt, PntAsVec, VecAsPnt, ColSlice, RowSlice, Diag, Eye}; -pub use self::operations::{Absolute, ApproxEq, Axpy, Cov, Det, Inv, LMul, Mean, Outer, PartialOrd, +pub use self::operations::{Absolute, ApproxEq, Axpy, Cov, Det, Inv, LMul, Mean, Outer, POrd, RMul, ScalarAdd, ScalarSub, ScalarMul, ScalarDiv, Transpose}; -pub use self::operations::{PartialOrdering, PartialLess, PartialEqual, PartialGreater, NotComparable}; +pub use self::operations::{POrdering, PartialLess, PartialEqual, PartialGreater, NotComparable}; pub mod geometry; pub mod structure; diff --git a/src/traits/operations.rs b/src/traits/operations.rs index 63901be9..430b1d2f 100644 --- a/src/traits/operations.rs +++ b/src/traits/operations.rs @@ -4,7 +4,7 @@ /// Result of a partial ordering. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Show)] -pub enum PartialOrdering { +pub enum POrdering { /// Result of a strict comparison. PartialLess, /// Equality relationship. @@ -15,7 +15,7 @@ pub enum PartialOrdering { NotComparable } -impl PartialOrdering { +impl POrdering { /// Returns `true` if `self` is equal to `Equal`. pub fn is_eq(&self) -> bool { *self == PartialEqual @@ -46,8 +46,8 @@ impl PartialOrdering { *self == NotComparable } - /// Creates a `PartialOrdering` from an `Ordering`. - pub fn from_ordering(ord: Ordering) -> PartialOrdering { + /// Creates a `POrdering` from an `Ordering`. + pub fn from_ordering(ord: Ordering) -> POrdering { match ord { Less => PartialLess, Equal => PartialEqual, @@ -55,7 +55,7 @@ impl PartialOrdering { } } - /// Converts this `PartialOrdering` to an `Ordering`. + /// Converts this `POrdering` to an `Ordering`. /// /// Returns `None` if `self` is `NotComparable`. pub fn to_ordering(self) -> Option { @@ -69,7 +69,7 @@ impl PartialOrdering { } /// Pointwise ordering operations. -pub trait PartialOrd { +pub trait POrd { /// Returns the infimum of `a` and `b`. fn inf(a: &Self, b: &Self) -> Self; @@ -77,36 +77,36 @@ pub trait PartialOrd { fn sup(a: &Self, b: &Self) -> Self; /// Compare `a` and `b` using a partial ordering relation. - fn partial_cmp(a: &Self, b: &Self) -> PartialOrdering; + fn partial_cmp(a: &Self, b: &Self) -> POrdering; /// Returns `true` iff `a` and `b` are comparable and `a <= b`. #[inline] fn partial_le(a: &Self, b: &Self) -> bool { - PartialOrd::partial_cmp(a, b).is_le() + POrd::partial_cmp(a, b).is_le() } /// Returns `true` iff `a` and `b` are comparable and `a < b`. #[inline] fn partial_lt(a: &Self, b: &Self) -> bool { - PartialOrd::partial_cmp(a, b).is_lt() + POrd::partial_cmp(a, b).is_lt() } /// Returns `true` iff `a` and `b` are comparable and `a >= b`. #[inline] fn partial_ge(a: &Self, b: &Self) -> bool { - PartialOrd::partial_cmp(a, b).is_ge() + POrd::partial_cmp(a, b).is_ge() } /// Returns `true` iff `a` and `b` are comparable and `a > b`. #[inline] fn partial_gt(a: &Self, b: &Self) -> bool { - PartialOrd::partial_cmp(a, b).is_gt() + POrd::partial_cmp(a, b).is_gt() } /// Return the minimum of `a` and `b` if they are comparable. #[inline] fn partial_min<'a>(a: &'a Self, b: &'a Self) -> Option<&'a Self> { - match PartialOrd::partial_cmp(a, b) { + match POrd::partial_cmp(a, b) { PartialLess | PartialEqual => Some(a), PartialGreater => Some(b), NotComparable => None @@ -116,7 +116,7 @@ pub trait PartialOrd { /// Return the maximum of `a` and `b` if they are comparable. #[inline] fn partial_max<'a>(a: &'a Self, b: &'a Self) -> Option<&'a Self> { - match PartialOrd::partial_cmp(a, b) { + match POrd::partial_cmp(a, b) { PartialGreater | PartialEqual => Some(a), PartialLess => Some(b), NotComparable => None @@ -127,8 +127,8 @@ pub trait PartialOrd { /// `min` or `max`. #[inline] fn partial_clamp<'a>(value: &'a Self, min: &'a Self, max: &'a Self) -> Option<&'a Self> { - let v_min = PartialOrd::partial_cmp(value, min); - let v_max = PartialOrd::partial_cmp(value, max); + let v_min = POrd::partial_cmp(value, min); + let v_max = POrd::partial_cmp(value, max); if v_min.is_not_comparable() || v_max.is_not_comparable() { None