-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<T>(in_x: T, in_y: T) -> <span class="prelude-ty">Result</span><i64, T> <span class="kw">where | ||
</span>i128: From<T>, | ||
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<T>(in_x: T, in_y: T) -> <span class="prelude-ty">Result</span><i64, T> <span class="kw">where | ||
</span>i128: From<T>, | ||
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> |