diff --git a/Cargo.lock b/Cargo.lock index fd88bf2..ca63699 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "safe_math" -version = "0.2.1" +version = "0.2.2" diff --git a/README.md b/README.md index f0d089b..9b31814 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ pub fn safe_add(in_x: T, in_y: T) -> Result where i128: From, T: Clone + Copy ``` -Takes two generic inputs of the same type, provided they are numbers or can be converted to 128 bit signed integers and implement the Copy trait, and adds them, if there is overflow it returns the larger of the two numbers in the Err Variant of the Result enum +Takes two generic inputs of the same type, provided they are numbers or can be converted to 128 bit signed integers and implement the Copy trait, and adds them, if there is overflow it returns the larger of the two numbers in the Err Variant of the Result enum, __only works with numbers as large as signed 64 bit integers__. #### safe_multiply(): ``` @@ -16,4 +16,4 @@ pub fn safe_multiply(in_x: T, in_y: T) -> Result where i128: From, T: Clone + Copy ``` -Does the same as [safe_add()](#header-4) but instead of adding it multiplies +Does the same as [safe_add()](#safe_add) but instead of adding it multiplies diff --git a/doc/README.html b/doc/README.html new file mode 100644 index 0000000..eaba66c --- /dev/null +++ b/doc/README.html @@ -0,0 +1,41 @@ + + + + + + + Safe Math + + + + + + + + +

Safe Math

+

§0.1 Math without overflow!

+

Adds two functions safe_add() and safe_multiply()

+

§0.1.1 src/safe_math.rs

§0.1.1.1 safe_add():

+
pub fn safe_add<T>(in_x: T, in_y: T) -> Result<i64, T> where
+  i128: From<T>,
+  T: Clone + Copy
+

Takes two generic inputs of the same type, provided they are numbers or can be converted to 128 bit signed integers and implement the Copy trait, and adds them, if there is overflow it returns the larger of the two numbers in the Err Variant of the Result enum, only works with numbers as large as signed 64 bit integers.

+

§0.1.1.2 safe_multiply():

+
pub fn safe_multiply<T>(in_x: T, in_y: T) -> Result<i64, T> where
+  i128: From<T>,
+  T: Clone + Copy
+

Does the same as safe_add() but instead of adding it multiplies

+ + + + \ No newline at end of file