do not return &mut Self in set_one/zero

This commit is contained in:
lcnr/Bastian Kauschke 2019-03-26 17:39:11 +01:00
parent d2a1e035ad
commit 87d4dbc418
1 changed files with 4 additions and 9 deletions

View File

@ -21,9 +21,8 @@ pub trait Zero: Sized + Add<Self, Output = Self> {
/// Sets `self` to the additive identity element of `Self`, `0`. /// Sets `self` to the additive identity element of `Self`, `0`.
/// Returns `&mut self` to enable method chaining. /// Returns `&mut self` to enable method chaining.
fn set_zero(&mut self) -> &mut Self { fn set_zero(&mut self) {
*self = Zero::zero(); *self = Zero::zero();
self
} }
/// Returns `true` if `self` is equal to the additive identity. /// Returns `true` if `self` is equal to the additive identity.
@ -73,9 +72,8 @@ where
self.0.is_zero() self.0.is_zero()
} }
fn set_zero(&mut self) -> &mut Self { fn set_zero(&mut self) {
self.0.set_zero(); self.0.set_zero();
self
} }
fn zero() -> Self { fn zero() -> Self {
@ -103,10 +101,8 @@ pub trait One: Sized + Mul<Self, Output = Self> {
fn one() -> Self; fn one() -> Self;
/// Sets `self` to the multiplicative identity element of `Self`, `1`. /// Sets `self` to the multiplicative identity element of `Self`, `1`.
/// Returns `&mut self` to enable method chaining. fn set_one(&mut self) {
fn set_one(&mut self) -> &mut Self {
*self = One::one(); *self = One::one();
self
} }
/// Returns `true` if `self` is equal to the multiplicative identity. /// Returns `true` if `self` is equal to the multiplicative identity.
@ -161,9 +157,8 @@ impl<T: One> One for Wrapping<T>
where where
Wrapping<T>: Mul<Output = Wrapping<T>>, Wrapping<T>: Mul<Output = Wrapping<T>>,
{ {
fn set_one(&mut self) -> &mut Self { fn set_one(&mut self) {
self.0.set_one(); self.0.set_one();
self
} }
fn one() -> Self { fn one() -> Self {