trait.CheckedShl.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 `CheckedShl` trait in crate `num_traits`.">
  8. <meta name="keywords" content="rust, rustlang, rust-lang, CheckedShl">
  9. <title>num_traits::ops::checked::CheckedShl - 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 trait">
  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'>Trait CheckedShl</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.checked_shl">checked_shl</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-CheckedShl">u64</a><a href="#impl-CheckedShl">usize</a><a href="#impl-CheckedShl">i8</a><a href="#impl-CheckedShl">isize</a><a href="#impl-CheckedShl">u32</a><a href="#impl-CheckedShl">u16</a><a href="#impl-CheckedShl">i16</a><a href="#impl-CheckedShl">i64</a><a href="#impl-CheckedShl">u8</a><a href="#impl-CheckedShl">i32</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../../index.html'>num_traits</a>::<wbr><a href='../index.html'>ops</a>::<wbr><a href='index.html'>checked</a></p><script>window.sidebarCurrent = {name: 'CheckedShl', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></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'>Trait <a href='../../index.html'>num_traits</a>::<wbr><a href='../index.html'>ops</a>::<wbr><a href='index.html'>checked</a>::<wbr><a class="trait" href=''>CheckedShl</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/ops/checked.rs.html#94-109' title='goto source code'>[src]</a></span></h1>
  50. <pre class='rust trait'>pub trait CheckedShl: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.Shl.html" title="trait core::ops::bit::Shl">Shl</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, Output = Self&gt; {
  51. fn <a href='#tymethod.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self&gt;;
  52. }</pre><div class='docblock'><p>Performs a left shift that returns <code>None</code> on overflow.</p>
  53. </div>
  54. <h2 id='required-methods' class='small-section-header'>
  55. Required Methods<a href='#required-methods' class='anchor'></a>
  56. </h2>
  57. <div class='methods'>
  58. <h3 id='tymethod.checked_shl' class='method'><span id='checked_shl.v' class='invisible'><code>fn <a href='#tymethod.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self&gt;</code></span></h3><div class='docblock'><p>Shifts a number to the left, checking for overflow. If overflow happens,
  59. <code>None</code> is returned.</p>
  60. <pre class="rust rust-example-rendered">
  61. <span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">CheckedShl</span>;
  62. <span class="kw">let</span> <span class="ident">x</span>: <span class="ident">u16</span> <span class="op">=</span> <span class="number">0x0001</span>;
  63. <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">CheckedShl</span>::<span class="ident">checked_shl</span>(<span class="kw-2">&amp;</span><span class="ident">x</span>, <span class="number">0</span>), <span class="prelude-val">Some</span>(<span class="number">0x0001</span>));
  64. <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">CheckedShl</span>::<span class="ident">checked_shl</span>(<span class="kw-2">&amp;</span><span class="ident">x</span>, <span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="number">0x0002</span>));
  65. <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">CheckedShl</span>::<span class="ident">checked_shl</span>(<span class="kw-2">&amp;</span><span class="ident">x</span>, <span class="number">15</span>), <span class="prelude-val">Some</span>(<span class="number">0x8000</span>));
  66. <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">CheckedShl</span>::<span class="ident">checked_shl</span>(<span class="kw-2">&amp;</span><span class="ident">x</span>, <span class="number">16</span>), <span class="prelude-val">None</span>);</pre>
  67. </div></div>
  68. <h2 id='foreign-impls' class='small-section-header'>
  69. Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
  70. </h2>
  71. <h3 id='impl-CheckedShl' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a href='#impl-CheckedShl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  72. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl' class="method"><span id='checked_shl.v-1' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  73. </div></span><h3 id='impl-CheckedShl-1' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a href='#impl-CheckedShl-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  74. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-1' class="method"><span id='checked_shl.v-2' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  75. </div></span><h3 id='impl-CheckedShl-2' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a href='#impl-CheckedShl-2' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  76. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-2' class="method"><span id='checked_shl.v-3' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  77. </div></span><h3 id='impl-CheckedShl-3' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a href='#impl-CheckedShl-3' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  78. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-3' class="method"><span id='checked_shl.v-4' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  79. </div></span><h3 id='impl-CheckedShl-4' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a href='#impl-CheckedShl-4' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  80. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-4' class="method"><span id='checked_shl.v-5' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  81. </div></span><h3 id='impl-CheckedShl-5' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a href='#impl-CheckedShl-5' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  82. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-5' class="method"><span id='checked_shl.v-6' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  83. </div></span><h3 id='impl-CheckedShl-6' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a href='#impl-CheckedShl-6' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  84. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-6' class="method"><span id='checked_shl.v-7' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  85. </div></span><h3 id='impl-CheckedShl-7' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code><a href='#impl-CheckedShl-7' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  86. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-7' class="method"><span id='checked_shl.v-8' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  87. </div></span><h3 id='impl-CheckedShl-8' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a href='#impl-CheckedShl-8' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  88. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-8' class="method"><span id='checked_shl.v-9' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  89. </div></span><h3 id='impl-CheckedShl-9' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../num_traits/ops/checked/trait.CheckedShl.html" title="trait num_traits::ops::checked::CheckedShl">CheckedShl</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a href='#impl-CheckedShl-9' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#113-118' title='goto source code'>[src]</a></span></h3>
  90. <span class='docblock autohide'><div class='impl-items'><h4 id='method.checked_shl-9' class="method"><span id='checked_shl.v-10' class='invisible'><code>fn <a href='#method.checked_shl' class='fnname'>checked_shl</a>(&amp;self, rhs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/num_traits/ops/checked.rs.html#115-117' title='goto source code'>[src]</a></span></h4>
  91. </div></span>
  92. <h2 id='implementors' class='small-section-header'>
  93. Implementors<a href='#implementors' class='anchor'></a>
  94. </h2>
  95. <ul class='item-list' id='implementors-list'>
  96. </ul><script type="text/javascript" async
  97. src="../../../implementors/num_traits/ops/checked/trait.CheckedShl.js">
  98. </script></section>
  99. <section id='search' class="content hidden"></section>
  100. <section class="footer"></section>
  101. <aside id="help" class="hidden">
  102. <div>
  103. <h1 class="hidden">Help</h1>
  104. <div class="shortcuts">
  105. <h2>Keyboard Shortcuts</h2>
  106. <dl>
  107. <dt><kbd>?</kbd></dt>
  108. <dd>Show this help dialog</dd>
  109. <dt><kbd>S</kbd></dt>
  110. <dd>Focus the search field</dd>
  111. <dt><kbd>↑</kbd></dt>
  112. <dd>Move up in search results</dd>
  113. <dt><kbd>↓</kbd></dt>
  114. <dd>Move down in search results</dd>
  115. <dt><kbd>↹</kbd></dt>
  116. <dd>Switch tab</dd>
  117. <dt><kbd>&#9166;</kbd></dt>
  118. <dd>Go to active search result</dd>
  119. <dt><kbd>+</kbd></dt>
  120. <dd>Expand all sections</dd>
  121. <dt><kbd>-</kbd></dt>
  122. <dd>Collapse all sections</dd>
  123. </dl>
  124. </div>
  125. <div class="infos">
  126. <h2>Search Tricks</h2>
  127. <p>
  128. Prefix searches with a type followed by a colon (e.g.
  129. <code>fn:</code>) to restrict the search to a given type.
  130. </p>
  131. <p>
  132. Accepted types are: <code>fn</code>, <code>mod</code>,
  133. <code>struct</code>, <code>enum</code>,
  134. <code>trait</code>, <code>type</code>, <code>macro</code>,
  135. and <code>const</code>.
  136. </p>
  137. <p>
  138. Search functions by type signature (e.g.
  139. <code>vec -> usize</code> or <code>* -> vec</code>)
  140. </p>
  141. </div>
  142. </div>
  143. </aside>
  144. <script>
  145. window.rootPath = "../../../";
  146. window.currentCrate = "num_traits";
  147. </script>
  148. <script src="../../../main.js"></script>
  149. <script defer src="../../../search-index.js"></script>
  150. </body>
  151. </html>