From 0f228be4d5744e48e0d8429ac5e9be12a37908b7 Mon Sep 17 00:00:00 2001 From: Roald Date: Sat, 21 Jul 2018 22:23:13 +0200 Subject: [PATCH 1/2] Updated documentation to note the pow(0, 0) case. --- src/pow.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pow.rs b/src/pow.rs index 7ef8d3f..e760dd3 100644 --- a/src/pow.rs +++ b/src/pow.rs @@ -173,6 +173,8 @@ mod float_impls { /// Raises a value to the power of exp, using exponentiation by squaring. /// +/// Note that `0⁰` (`pow(0, 0)`) returnes `1`. Mathematicly this is undefined. +/// /// # Example /// /// ```rust @@ -180,6 +182,7 @@ mod float_impls { /// /// assert_eq!(pow(2i8, 4), 16); /// assert_eq!(pow(6u8, 3), 216); +/// assert_eq!(pow(0u8, 0), 1); // Be aware if this case affects you /// ``` #[inline] pub fn pow>(mut base: T, mut exp: usize) -> T { @@ -208,6 +211,8 @@ pub fn pow>(mut base: T, mut exp: usize) -> /// Raises a value to the power of exp, returning `None` if an overflow occurred. /// +/// Note that `0⁰` (`checked_pow(0, 0)`) returnes `Some(1)`. Mathematicly this is undefined. +/// /// Otherwise same as the `pow` function. /// /// # Example @@ -218,6 +223,7 @@ pub fn pow>(mut base: T, mut exp: usize) -> /// assert_eq!(checked_pow(2i8, 4), Some(16)); /// assert_eq!(checked_pow(7i8, 8), None); /// assert_eq!(checked_pow(7u32, 8), Some(5_764_801)); +/// assert_eq!(checked_pow(0u32, 0), Some(1)); // Be aware if this case affect you /// ``` #[inline] pub fn checked_pow(mut base: T, mut exp: usize) -> Option { From 2b975badfacf42ddaf127ce6abf518422cf32824 Mon Sep 17 00:00:00 2001 From: Roald Date: Tue, 7 Aug 2018 12:56:16 +0200 Subject: [PATCH 2/2] typo --- src/pow.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.rs b/src/pow.rs index e760dd3..daecb8e 100644 --- a/src/pow.rs +++ b/src/pow.rs @@ -173,7 +173,7 @@ mod float_impls { /// Raises a value to the power of exp, using exponentiation by squaring. /// -/// Note that `0⁰` (`pow(0, 0)`) returnes `1`. Mathematicly this is undefined. +/// Note that `0⁰` (`pow(0, 0)`) returnes `1`. Mathematically this is undefined. /// /// # Example /// @@ -211,7 +211,7 @@ pub fn pow>(mut base: T, mut exp: usize) -> /// Raises a value to the power of exp, returning `None` if an overflow occurred. /// -/// Note that `0⁰` (`checked_pow(0, 0)`) returnes `Some(1)`. Mathematicly this is undefined. +/// Note that `0⁰` (`checked_pow(0, 0)`) returnes `Some(1)`. Mathematically this is undefined. /// /// Otherwise same as the `pow` function. ///