From 80052795ba18ec15889da400f9297185e4337cbf Mon Sep 17 00:00:00 2001 From: lcnr/Bastian Kauschke Date: Tue, 5 Mar 2019 14:45:54 +0100 Subject: [PATCH] fix --- src/identities.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/identities.rs b/src/identities.rs index 437fbc1..0b0e0e6 100644 --- a/src/identities.rs +++ b/src/identities.rs @@ -22,7 +22,7 @@ pub trait Zero: Sized + Add { fn zero() -> Self; /// Sets `self` to the additive identity element of `Self`, `0`. - /// This function may be faster than replacing self with `Zero::zero()`. + /// Returns `&mut self` to enable method chaining. /// /// # Laws /// @@ -30,10 +30,6 @@ pub trait Zero: Sized + Add { /// a + 0 = a ∀ a ∈ Self /// 0 + a = a ∀ a ∈ Self /// ``` - /// - /// # Purity - /// - /// This function may return different results depending on the previous state of `self`. fn to_zero(&mut self) -> &mut Self { mem::replace(self, Zero::zero()); self @@ -110,6 +106,7 @@ pub trait One: Sized + Mul { fn one() -> Self; /// Sets `self` to the multiplicative identity element of `Self`, `1`. + /// Returns `&mut self` to enable method chaining. /// /// # Laws /// @@ -117,11 +114,7 @@ pub trait One: Sized + Mul { /// a * 1 = a ∀ a ∈ Self /// 1 * a = a ∀ a ∈ Self /// ``` - /// - /// # Purity - /// - /// This function may return different results depending on the previous state of `self`. - fn to_zero(&mut self) -> &mut Self { + fn to_one(&mut self) -> &mut Self { mem::replace(self, One::one()); self }