Skip to content

Commit 53cbc45

Browse files
sshilovskycuviper
authored andcommitted
Highlight difference in traits' abstraction level
Short descriptions for NumOps sort of blended in with NumRef and RefNum. This suggests to clarify the difference a little bit more.
1 parent 42e3f95 commit 53cbc45

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub trait Num: PartialEq + Zero + One + NumOps {
9595
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>;
9696
}
9797

98-
/// The trait for types implementing basic numeric operations
98+
/// Generic trait for types implementing basic numeric operations
9999
///
100100
/// This is automatically implemented for types which implement the operators.
101101
pub trait NumOps<Rhs = Self, Output = Self>:
@@ -123,14 +123,16 @@ impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
123123
pub trait NumRef: Num + for<'r> NumOps<&'r Self> {}
124124
impl<T> NumRef for T where T: Num + for<'r> NumOps<&'r T> {}
125125

126-
/// The trait for references which implement numeric operations, taking the
126+
/// The trait for `Num` references which implement numeric operations, taking the
127127
/// second operand either by value or by reference.
128128
///
129-
/// This is automatically implemented for types which implement the operators.
129+
/// This is automatically implemented for all types which implement the operators. It covers
130+
/// every type implementing the operations though, regardless of it being a reference or
131+
/// related to `Num`.
130132
pub trait RefNum<Base>: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
131133
impl<T, Base> RefNum<Base> for T where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
132134

133-
/// The trait for types implementing numeric assignment operators (like `+=`).
135+
/// Generic trait for types implementing numeric assignment operators (like `+=`).
134136
///
135137
/// This is automatically implemented for types which implement the operators.
136138
pub trait NumAssignOps<Rhs = Self>:

0 commit comments

Comments
 (0)