index.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <!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"><meta name="description" content="API documentation for the Rust `num_traits` crate."><meta name="keywords" content="rust, rustlang, rust-lang, num_traits"><title>num_traits - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Crate num_traits</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'num_traits', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Crate <a class="mod" href=''>num_traits</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/num_traits/lib.rs.html#11-88' title='goto source code'>[src]</a></span></h1><div class='docblock'><p>Numeric traits for generic mathematics</p>
  2. <p>This version of the crate only exists to re-export compatible
  3. items from num-traits 0.2. Please consider updating!</p>
  4. </div><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
  5. <table>
  6. <tr class=' module-item'>
  7. <td><a class="mod" href="bounds/index.html"
  8. title='mod num_traits::bounds'>bounds</a></td>
  9. <td class='docblock-short'>
  10. </td>
  11. </tr>
  12. <tr class=' module-item'>
  13. <td><a class="mod" href="cast/index.html"
  14. title='mod num_traits::cast'>cast</a></td>
  15. <td class='docblock-short'>
  16. </td>
  17. </tr>
  18. <tr class=' module-item'>
  19. <td><a class="mod" href="float/index.html"
  20. title='mod num_traits::float'>float</a></td>
  21. <td class='docblock-short'>
  22. </td>
  23. </tr>
  24. <tr class=' module-item'>
  25. <td><a class="mod" href="identities/index.html"
  26. title='mod num_traits::identities'>identities</a></td>
  27. <td class='docblock-short'>
  28. </td>
  29. </tr>
  30. <tr class=' module-item'>
  31. <td><a class="mod" href="int/index.html"
  32. title='mod num_traits::int'>int</a></td>
  33. <td class='docblock-short'>
  34. </td>
  35. </tr>
  36. <tr class=' module-item'>
  37. <td><a class="mod" href="ops/index.html"
  38. title='mod num_traits::ops'>ops</a></td>
  39. <td class='docblock-short'>
  40. </td>
  41. </tr>
  42. <tr class=' module-item'>
  43. <td><a class="mod" href="pow/index.html"
  44. title='mod num_traits::pow'>pow</a></td>
  45. <td class='docblock-short'>
  46. </td>
  47. </tr>
  48. <tr class=' module-item'>
  49. <td><a class="mod" href="real/index.html"
  50. title='mod num_traits::real'>real</a></td>
  51. <td class='docblock-short'>
  52. </td>
  53. </tr>
  54. <tr class=' module-item'>
  55. <td><a class="mod" href="sign/index.html"
  56. title='mod num_traits::sign'>sign</a></td>
  57. <td class='docblock-short'>
  58. </td>
  59. </tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
  60. <table>
  61. <tr class=' module-item'>
  62. <td><a class="struct" href="struct.ParseFloatError.html"
  63. title='struct num_traits::ParseFloatError'>ParseFloatError</a></td>
  64. <td class='docblock-short'>
  65. </td>
  66. </tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
  67. <table>
  68. <tr class=' module-item'>
  69. <td><a class="enum" href="enum.FloatErrorKind.html"
  70. title='enum num_traits::FloatErrorKind'>FloatErrorKind</a></td>
  71. <td class='docblock-short'>
  72. </td>
  73. </tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
  74. <table>
  75. <tr class=' module-item'>
  76. <td><a class="trait" href="trait.AsPrimitive.html"
  77. title='trait num_traits::AsPrimitive'>AsPrimitive</a></td>
  78. <td class='docblock-short'>
  79. <p>A generic interface for casting between machine scalars with the
  80. <code>as</code> operator, which admits narrowing and precision loss.
  81. Implementers of this trait AsPrimitive should behave like a primitive
  82. numeric type (e.g. a newtype around another primitive), and the
  83. intended conversion must never fail.</p>
  84. </td>
  85. </tr>
  86. <tr class=' module-item'>
  87. <td><a class="trait" href="trait.Bounded.html"
  88. title='trait num_traits::Bounded'>Bounded</a></td>
  89. <td class='docblock-short'>
  90. <p>Numbers which have upper and lower bounds</p>
  91. </td>
  92. </tr>
  93. <tr class=' module-item'>
  94. <td><a class="trait" href="trait.CheckedAdd.html"
  95. title='trait num_traits::CheckedAdd'>CheckedAdd</a></td>
  96. <td class='docblock-short'>
  97. <p>Performs addition that returns <code>None</code> instead of wrapping around on
  98. overflow.</p>
  99. </td>
  100. </tr>
  101. <tr class=' module-item'>
  102. <td><a class="trait" href="trait.CheckedDiv.html"
  103. title='trait num_traits::CheckedDiv'>CheckedDiv</a></td>
  104. <td class='docblock-short'>
  105. <p>Performs division that returns <code>None</code> instead of panicking on division by zero and instead of
  106. wrapping around on underflow and overflow.</p>
  107. </td>
  108. </tr>
  109. <tr class=' module-item'>
  110. <td><a class="trait" href="trait.CheckedMul.html"
  111. title='trait num_traits::CheckedMul'>CheckedMul</a></td>
  112. <td class='docblock-short'>
  113. <p>Performs multiplication that returns <code>None</code> instead of wrapping around on underflow or
  114. overflow.</p>
  115. </td>
  116. </tr>
  117. <tr class=' module-item'>
  118. <td><a class="trait" href="trait.CheckedShl.html"
  119. title='trait num_traits::CheckedShl'>CheckedShl</a></td>
  120. <td class='docblock-short'>
  121. <p>Performs a left shift that returns <code>None</code> on overflow.</p>
  122. </td>
  123. </tr>
  124. <tr class=' module-item'>
  125. <td><a class="trait" href="trait.CheckedShr.html"
  126. title='trait num_traits::CheckedShr'>CheckedShr</a></td>
  127. <td class='docblock-short'>
  128. <p>Performs a right shift that returns <code>None</code> on overflow.</p>
  129. </td>
  130. </tr>
  131. <tr class=' module-item'>
  132. <td><a class="trait" href="trait.CheckedSub.html"
  133. title='trait num_traits::CheckedSub'>CheckedSub</a></td>
  134. <td class='docblock-short'>
  135. <p>Performs subtraction that returns <code>None</code> instead of wrapping around on underflow.</p>
  136. </td>
  137. </tr>
  138. <tr class=' module-item'>
  139. <td><a class="trait" href="trait.Float.html"
  140. title='trait num_traits::Float'>Float</a></td>
  141. <td class='docblock-short'>
  142. <p>Generic trait for floating point numbers</p>
  143. </td>
  144. </tr>
  145. <tr class=' module-item'>
  146. <td><a class="trait" href="trait.FloatConst.html"
  147. title='trait num_traits::FloatConst'>FloatConst</a></td>
  148. <td class='docblock-short'>
  149. </td>
  150. </tr>
  151. <tr class=' module-item'>
  152. <td><a class="trait" href="trait.FromPrimitive.html"
  153. title='trait num_traits::FromPrimitive'>FromPrimitive</a></td>
  154. <td class='docblock-short'>
  155. <p>A generic trait for converting a number to a value.</p>
  156. </td>
  157. </tr>
  158. <tr class=' module-item'>
  159. <td><a class="trait" href="trait.Num.html"
  160. title='trait num_traits::Num'>Num</a></td>
  161. <td class='docblock-short'>
  162. <p>The base trait for numeric types, covering <code>0</code> and <code>1</code> values,
  163. comparisons, basic numeric operations, and string conversion.</p>
  164. </td>
  165. </tr>
  166. <tr class=' module-item'>
  167. <td><a class="trait" href="trait.NumAssign.html"
  168. title='trait num_traits::NumAssign'>NumAssign</a></td>
  169. <td class='docblock-short'>
  170. <p>The trait for <code>Num</code> types which also implement assignment operators.</p>
  171. </td>
  172. </tr>
  173. <tr class=' module-item'>
  174. <td><a class="trait" href="trait.NumAssignOps.html"
  175. title='trait num_traits::NumAssignOps'>NumAssignOps</a></td>
  176. <td class='docblock-short'>
  177. <p>The trait for types implementing numeric assignment operators (like <code>+=</code>).</p>
  178. </td>
  179. </tr>
  180. <tr class=' module-item'>
  181. <td><a class="trait" href="trait.NumAssignRef.html"
  182. title='trait num_traits::NumAssignRef'>NumAssignRef</a></td>
  183. <td class='docblock-short'>
  184. <p>The trait for <code>NumAssign</code> types which also implement assignment operations
  185. taking the second operand by reference.</p>
  186. </td>
  187. </tr>
  188. <tr class=' module-item'>
  189. <td><a class="trait" href="trait.NumCast.html"
  190. title='trait num_traits::NumCast'>NumCast</a></td>
  191. <td class='docblock-short'>
  192. <p>An interface for casting between machine scalars.</p>
  193. </td>
  194. </tr>
  195. <tr class=' module-item'>
  196. <td><a class="trait" href="trait.NumOps.html"
  197. title='trait num_traits::NumOps'>NumOps</a></td>
  198. <td class='docblock-short'>
  199. <p>The trait for types implementing basic numeric operations</p>
  200. </td>
  201. </tr>
  202. <tr class=' module-item'>
  203. <td><a class="trait" href="trait.NumRef.html"
  204. title='trait num_traits::NumRef'>NumRef</a></td>
  205. <td class='docblock-short'>
  206. <p>The trait for <code>Num</code> types which also implement numeric operations taking
  207. the second operand by reference.</p>
  208. </td>
  209. </tr>
  210. <tr class=' module-item'>
  211. <td><a class="trait" href="trait.One.html"
  212. title='trait num_traits::One'>One</a></td>
  213. <td class='docblock-short'>
  214. <p>Defines a multiplicative identity element for <code>Self</code>.</p>
  215. </td>
  216. </tr>
  217. <tr class=' module-item'>
  218. <td><a class="trait" href="trait.PrimInt.html"
  219. title='trait num_traits::PrimInt'>PrimInt</a></td>
  220. <td class='docblock-short'>
  221. </td>
  222. </tr>
  223. <tr class=' module-item'>
  224. <td><a class="trait" href="trait.RefNum.html"
  225. title='trait num_traits::RefNum'>RefNum</a></td>
  226. <td class='docblock-short'>
  227. <p>The trait for references which implement numeric operations, taking the
  228. second operand either by value or by reference.</p>
  229. </td>
  230. </tr>
  231. <tr class=' module-item'>
  232. <td><a class="trait" href="trait.Saturating.html"
  233. title='trait num_traits::Saturating'>Saturating</a></td>
  234. <td class='docblock-short'>
  235. <p>Saturating math operations</p>
  236. </td>
  237. </tr>
  238. <tr class=' module-item'>
  239. <td><a class="trait" href="trait.Signed.html"
  240. title='trait num_traits::Signed'>Signed</a></td>
  241. <td class='docblock-short'>
  242. <p>Useful functions for signed numbers (i.e. numbers that can be negative).</p>
  243. </td>
  244. </tr>
  245. <tr class=' module-item'>
  246. <td><a class="trait" href="trait.ToPrimitive.html"
  247. title='trait num_traits::ToPrimitive'>ToPrimitive</a></td>
  248. <td class='docblock-short'>
  249. <p>A generic trait for converting a value to a number.</p>
  250. </td>
  251. </tr>
  252. <tr class=' module-item'>
  253. <td><a class="trait" href="trait.Unsigned.html"
  254. title='trait num_traits::Unsigned'>Unsigned</a></td>
  255. <td class='docblock-short'>
  256. <p>A trait for values which cannot be negative</p>
  257. </td>
  258. </tr>
  259. <tr class=' module-item'>
  260. <td><a class="trait" href="trait.WrappingAdd.html"
  261. title='trait num_traits::WrappingAdd'>WrappingAdd</a></td>
  262. <td class='docblock-short'>
  263. <p>Performs addition that wraps around on overflow.</p>
  264. </td>
  265. </tr>
  266. <tr class=' module-item'>
  267. <td><a class="trait" href="trait.WrappingMul.html"
  268. title='trait num_traits::WrappingMul'>WrappingMul</a></td>
  269. <td class='docblock-short'>
  270. <p>Performs multiplication that wraps around on overflow.</p>
  271. </td>
  272. </tr>
  273. <tr class=' module-item'>
  274. <td><a class="trait" href="trait.WrappingSub.html"
  275. title='trait num_traits::WrappingSub'>WrappingSub</a></td>
  276. <td class='docblock-short'>
  277. <p>Performs subtraction that wraps around on overflow.</p>
  278. </td>
  279. </tr>
  280. <tr class=' module-item'>
  281. <td><a class="trait" href="trait.Zero.html"
  282. title='trait num_traits::Zero'>Zero</a></td>
  283. <td class='docblock-short'>
  284. <p>Defines an additive identity element for <code>Self</code>.</p>
  285. </td>
  286. </tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
  287. <table>
  288. <tr class=' module-item'>
  289. <td><a class="fn" href="fn.abs.html"
  290. title='fn num_traits::abs'>abs</a></td>
  291. <td class='docblock-short'>
  292. <p>Computes the absolute value.</p>
  293. </td>
  294. </tr>
  295. <tr class=' module-item'>
  296. <td><a class="fn" href="fn.abs_sub.html"
  297. title='fn num_traits::abs_sub'>abs_sub</a></td>
  298. <td class='docblock-short'>
  299. <p>The positive difference of two numbers.</p>
  300. </td>
  301. </tr>
  302. <tr class=' module-item'>
  303. <td><a class="fn" href="fn.cast.html"
  304. title='fn num_traits::cast'>cast</a></td>
  305. <td class='docblock-short'>
  306. <p>Cast from one machine scalar to another.</p>
  307. </td>
  308. </tr>
  309. <tr class=' module-item'>
  310. <td><a class="fn" href="fn.checked_pow.html"
  311. title='fn num_traits::checked_pow'>checked_pow</a></td>
  312. <td class='docblock-short'>
  313. <p>Raises a value to the power of exp, returning <code>None</code> if an overflow occurred.</p>
  314. </td>
  315. </tr>
  316. <tr class=' module-item'>
  317. <td><a class="fn" href="fn.clamp.html"
  318. title='fn num_traits::clamp'>clamp</a></td>
  319. <td class='docblock-short'>
  320. <p>A value bounded by a minimum and a maximum</p>
  321. </td>
  322. </tr>
  323. <tr class=' module-item'>
  324. <td><a class="fn" href="fn.one.html"
  325. title='fn num_traits::one'>one</a></td>
  326. <td class='docblock-short'>
  327. <p>Returns the multiplicative identity, <code>1</code>.</p>
  328. </td>
  329. </tr>
  330. <tr class=' module-item'>
  331. <td><a class="fn" href="fn.pow.html"
  332. title='fn num_traits::pow'>pow</a></td>
  333. <td class='docblock-short'>
  334. <p>Raises a value to the power of exp, using exponentiation by squaring.</p>
  335. </td>
  336. </tr>
  337. <tr class=' module-item'>
  338. <td><a class="fn" href="fn.signum.html"
  339. title='fn num_traits::signum'>signum</a></td>
  340. <td class='docblock-short'>
  341. <p>Returns the sign of the number.</p>
  342. </td>
  343. </tr>
  344. <tr class=' module-item'>
  345. <td><a class="fn" href="fn.zero.html"
  346. title='fn num_traits::zero'>zero</a></td>
  347. <td class='docblock-short'>
  348. <p>Returns the additive identity, <code>0</code>.</p>
  349. </td>
  350. </tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "num_traits";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>