Skip to content

Commit

Permalink
Updated README.md and added to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
26CAllen committed Sep 24, 2024
1 parent 3f33486 commit 3f8b57f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ 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
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():
```
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()](#header-4) but instead of adding it multiplies
Does the same as [safe_add()](#safe_add) but instead of adding it multiplies
41 changes: 41 additions & 0 deletions doc/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<title>Safe Math</title>



</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->


<h1 class="title">Safe Math</h1>
<nav id="TOC"><ul>
<li><a href="#math-without-overflow">0.1 Math without overflow!</a><ul>
<li><a href="#srcsafe_mathrs">0.1.1 <a href="https://github.com/XDDudeGuy/safe_math/blob/master/src/safe_operations.rs">src/safe_math.rs</a></a><ul>
<li><a href="#safe_add">0.1.1.1 safe_add():</a><ul></ul></li>
<li><a href="#safe_multiply">0.1.1.2 safe_multiply():</a><ul></ul></li></ul></li></ul></li></ul></nav><h2 id="math-without-overflow"><a class="doc-anchor" href="#math-without-overflow">§</a>0.1 Math without overflow!</h2>
<p>Adds two functions <code>safe_add()</code> and <code>safe_multiply()</code></p>
<h3 id="srcsafe_mathrs"><a class="doc-anchor" href="#srcsafe_mathrs">§</a>0.1.1 <a href="https://github.com/XDDudeGuy/safe_math/blob/master/src/safe_operations.rs">src/safe_math.rs</a></h3><h4 id="safe_add"><a class="doc-anchor" href="#safe_add">§</a>0.1.1.1 safe_add():</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">pub fn </span>safe_add&lt;T&gt;(in_x: T, in_y: T) -&gt; <span class="prelude-ty">Result</span>&lt;i64, T&gt; <span class="kw">where
</span>i128: From&lt;T&gt;,
T: Clone + Copy</code></pre></div>
<p>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, <strong>only works with numbers as large as signed 64 bit integers</strong>.</p>
<h4 id="safe_multiply"><a class="doc-anchor" href="#safe_multiply">§</a>0.1.1.2 safe_multiply():</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">pub fn </span>safe_multiply&lt;T&gt;(in_x: T, in_y: T) -&gt; <span class="prelude-ty">Result</span>&lt;i64, T&gt; <span class="kw">where
</span>i128: From&lt;T&gt;,
T: Clone + Copy</code></pre></div>
<p>Does the same as <a href="#safe_add">safe_add()</a> but instead of adding it multiplies</p>


</body>
</html>

0 comments on commit 3f8b57f

Please sign in to comment.