blob: 26ecc7c3e883c9ee0e302598e5e65c7c70320e6d [file] [log] [blame]
<!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="Performs a right shift that does not panic."><meta name="keywords" content="rust, rustlang, rust-lang, WrappingShr"><title>WrappingShr in num::traits - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../num/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../num/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">WrappingShr</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.wrapping_shr">wrapping_shr</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-WrappingShr-for-Wrapping%3CT%3E">Wrapping&lt;T&gt;</a></li><li><a href="#impl-WrappingShr-for-i128">i128</a></li><li><a href="#impl-WrappingShr-for-i16">i16</a></li><li><a href="#impl-WrappingShr-for-i32">i32</a></li><li><a href="#impl-WrappingShr-for-i64">i64</a></li><li><a href="#impl-WrappingShr-for-i8">i8</a></li><li><a href="#impl-WrappingShr-for-isize">isize</a></li><li><a href="#impl-WrappingShr-for-u128">u128</a></li><li><a href="#impl-WrappingShr-for-u16">u16</a></li><li><a href="#impl-WrappingShr-for-u32">u32</a></li><li><a href="#impl-WrappingShr-for-u64">u64</a></li><li><a href="#impl-WrappingShr-for-u8">u8</a></li><li><a href="#impl-WrappingShr-for-usize">usize</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In num::traits</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="../index.html">num</a>::<wbr><a href="index.html">traits</a>::<wbr><a class="trait" href="#">WrappingShr</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/num_traits/ops/wrapping.rs.html#187">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait WrappingShr: Shr&lt;usize, Output = Self&gt; {
fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; Self;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Performs a right shift that does not panic.</p>
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.wrapping_shr" class="method has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#202">source</a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; Self</h4></section></summary><div class="docblock"><p>Panic-free bitwise shift-right; yields <code>self &gt;&gt; mask(rhs)</code>,
where <code>mask</code> removes any high order bits of <code>rhs</code> that would
cause the shift to exceed the bitwidth of the type.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::WrappingShr;
<span class="kw">let </span>x: u16 = <span class="number">0x8000</span>;
<span class="macro">assert_eq!</span>(WrappingShr::wrapping_shr(<span class="kw-2">&amp;</span>x, <span class="number">0</span>), <span class="number">0x8000</span>);
<span class="macro">assert_eq!</span>(WrappingShr::wrapping_shr(<span class="kw-2">&amp;</span>x, <span class="number">1</span>), <span class="number">0x4000</span>);
<span class="macro">assert_eq!</span>(WrappingShr::wrapping_shr(<span class="kw-2">&amp;</span>x, <span class="number">15</span>), <span class="number">0x0001</span>);
<span class="macro">assert_eq!</span>(WrappingShr::wrapping_shr(<span class="kw-2">&amp;</span>x, <span class="number">16</span>), <span class="number">0x8000</span>);</code></pre></div>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-i128" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#219">source</a><a href="#impl-WrappingShr-for-i128" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for i128</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#219">source</a><a href="#method.wrapping_shr" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; i128</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-i32" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#215">source</a><a href="#impl-WrappingShr-for-i32" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for i32</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#215">source</a><a href="#method.wrapping_shr-1" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; i32</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-u64" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#208">source</a><a href="#impl-WrappingShr-for-u64" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for u64</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#208">source</a><a href="#method.wrapping_shr-2" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; u64</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-u32" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#207">source</a><a href="#impl-WrappingShr-for-u32" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for u32</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#207">source</a><a href="#method.wrapping_shr-3" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; u32</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-Wrapping%3CT%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#262">source</a><a href="#impl-WrappingShr-for-Wrapping%3CT%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for Wrapping&lt;T&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Wrapping&lt;T&gt;: Shr&lt;usize, Output = Wrapping&lt;T&gt;&gt;,</span></h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#266">source</a><a href="#method.wrapping_shr-4" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; Wrapping&lt;T&gt;</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-i16" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#214">source</a><a href="#impl-WrappingShr-for-i16" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for i16</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#214">source</a><a href="#method.wrapping_shr-5" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; i16</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-usize" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#209">source</a><a href="#impl-WrappingShr-for-usize" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for usize</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-6" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#209">source</a><a href="#method.wrapping_shr-6" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; usize</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-i64" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#216">source</a><a href="#impl-WrappingShr-for-i64" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for i64</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-7" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#216">source</a><a href="#method.wrapping_shr-7" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; i64</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-u128" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#211">source</a><a href="#impl-WrappingShr-for-u128" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for u128</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-8" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#211">source</a><a href="#method.wrapping_shr-8" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; u128</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-u8" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#205">source</a><a href="#impl-WrappingShr-for-u8" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for u8</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-9" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#205">source</a><a href="#method.wrapping_shr-9" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; u8</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-i8" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#213">source</a><a href="#impl-WrappingShr-for-i8" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for i8</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-10" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#213">source</a><a href="#method.wrapping_shr-10" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; i8</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-u16" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#206">source</a><a href="#impl-WrappingShr-for-u16" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for u16</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-11" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#206">source</a><a href="#method.wrapping_shr-11" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; u16</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WrappingShr-for-isize" class="impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#217">source</a><a href="#impl-WrappingShr-for-isize" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.WrappingShr.html" title="trait num::traits::WrappingShr">WrappingShr</a> for isize</h3></section></summary><div class="impl-items"><section id="method.wrapping_shr-12" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/num_traits/ops/wrapping.rs.html#217">source</a><a href="#method.wrapping_shr-12" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.wrapping_shr" class="fnname">wrapping_shr</a>(&amp;self, rhs: u32) -&gt; isize</h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"></div><script src="../../implementors/num_traits/ops/wrapping/trait.WrappingShr.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="num" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>