index.html 25 KB

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