|
@@ -95,7 +95,7 @@ pub trait Num: PartialEq + Zero + One + NumOps {
|
|
|
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>;
|
|
|
}
|
|
|
|
|
|
-/// The trait for types implementing basic numeric operations
|
|
|
+/// Generic trait for types implementing basic numeric operations
|
|
|
///
|
|
|
/// This is automatically implemented for types which implement the operators.
|
|
|
pub trait NumOps<Rhs = Self, Output = Self>:
|
|
@@ -123,14 +123,16 @@ impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
|
|
|
pub trait NumRef: Num + for<'r> NumOps<&'r Self> {}
|
|
|
impl<T> NumRef for T where T: Num + for<'r> NumOps<&'r T> {}
|
|
|
|
|
|
-/// The trait for references which implement numeric operations, taking the
|
|
|
+/// The trait for `Num` references which implement numeric operations, taking the
|
|
|
/// second operand either by value or by reference.
|
|
|
///
|
|
|
-/// This is automatically implemented for types which implement the operators.
|
|
|
+/// This is automatically implemented for all types which implement the operators. It covers
|
|
|
+/// every type implementing the operations though, regardless of it being a reference or
|
|
|
+/// related to `Num`.
|
|
|
pub trait RefNum<Base>: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
|
|
|
impl<T, Base> RefNum<Base> for T where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
|
|
|
|
|
|
-/// The trait for types implementing numeric assignment operators (like `+=`).
|
|
|
+/// Generic trait for types implementing numeric assignment operators (like `+=`).
|
|
|
///
|
|
|
/// This is automatically implemented for types which implement the operators.
|
|
|
pub trait NumAssignOps<Rhs = Self>:
|