blob: 6f9285adf01e1d7dca1919460fabff42a9b7bd6d [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="A trait which indicates that a type is a `#[repr(transparent)]` wrapper around the `Inner` value."><meta name="keywords" content="rust, rustlang, rust-lang, TransparentWrapper"><title>TransparentWrapper in bytemuck - 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="../bytemuck/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="../bytemuck/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">TransparentWrapper</a></h2><div class="sidebar-elems"><section><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.peel">peel</a></li><li><a href="#method.peel_mut">peel_mut</a></li><li><a href="#method.peel_ref">peel_ref</a></li><li><a href="#method.peel_slice">peel_slice</a></li><li><a href="#method.peel_slice_mut">peel_slice_mut</a></li><li><a href="#method.wrap">wrap</a></li><li><a href="#method.wrap_mut">wrap_mut</a></li><li><a href="#method.wrap_ref">wrap_ref</a></li><li><a href="#method.wrap_slice">wrap_slice</a></li><li><a href="#method.wrap_slice_mut">wrap_slice_mut</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-TransparentWrapper%3CT%3E-for-Wrapping%3CT%3E">Wrapping&lt;T&gt;</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In bytemuck</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">bytemuck</a>::<wbr><a class="trait" href="#">TransparentWrapper</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/bytemuck/transparent.rs.html#126-286">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 unsafe trait TransparentWrapper&lt;Inner:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; {
fn <a href="#method.wrap" class="fnname">wrap</a>(s: Inner) -&gt; Self<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<span class="item-spacer"></span> fn <a href="#method.wrap_ref" class="fnname">wrap_ref</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Inner) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Self { ... }
<span class="item-spacer"></span> fn <a href="#method.wrap_mut" class="fnname">wrap_mut</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Inner) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Self { ... }
<span class="item-spacer"></span> fn <a href="#method.wrap_slice" class="fnname">wrap_slice</a>(s: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a>) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<span class="item-spacer"></span> fn <a href="#method.wrap_slice_mut" class="fnname">wrap_slice_mut</a>(s: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<span class="item-spacer"></span> fn <a href="#method.peel" class="fnname">peel</a>(s: Self) -&gt; Inner<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<span class="item-spacer"></span> fn <a href="#method.peel_ref" class="fnname">peel_ref</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Inner { ... }
<span class="item-spacer"></span> fn <a href="#method.peel_mut" class="fnname">peel_mut</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Inner { ... }
<span class="item-spacer"></span> fn <a href="#method.peel_slice" class="fnname">peel_slice</a>(s: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a>) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<span class="item-spacer"></span> fn <a href="#method.peel_slice_mut" class="fnname">peel_slice_mut</a>(s: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A trait which indicates that a type is a <code>#[repr(transparent)]</code> wrapper
around the <code>Inner</code> value.</p>
<p>This allows safely copy transmuting between the <code>Inner</code> type and the
<code>TransparentWrapper</code> type. Functions like <code>wrap_{}</code> convert from the inner
type to the wrapper type and <code>peel_{}</code> functions do the inverse conversion
from the wrapper type to the inner type. We deliberately do not call the
wrapper-removing methods “unwrap” because at this point that word is too
strongly tied to the Option/ Result methods.</p>
<h2 id="safety"><a href="#safety">Safety</a></h2>
<p>The safety contract of <code>TransparentWrapper</code> is relatively simple:</p>
<p>For a given <code>Wrapper</code> which implements <code>TransparentWrapper&lt;Inner&gt;</code>:</p>
<ol>
<li>
<p><code>Wrapper</code> must be a wrapper around <code>Inner</code> with an identical data
representations. This either means that it must be a
<code>#[repr(transparent)]</code> struct which contains a either a field of type
<code>Inner</code> (or a field of some other transparent wrapper for <code>Inner</code>) as
the only non-ZST field.</p>
</li>
<li>
<p>Any fields <em>other</em> than the <code>Inner</code> field must be trivially constructable
ZSTs, for example <code>PhantomData</code>, <code>PhantomPinned</code>, etc. (When deriving
<code>TransparentWrapper</code> on a type with ZST fields, the ZST fields must be
<a href="trait.Zeroable.html" title="Zeroable"><code>Zeroable</code></a>).</p>
</li>
<li>
<p>The <code>Wrapper</code> may not impose additional alignment requirements over
<code>Inner</code>.</p>
<ul>
<li>Note: this is currently guaranteed by <code>repr(transparent)</code>, but there
have been discussions of lifting it, so it’s stated here explicitly.</li>
</ul>
</li>
<li>
<p>All functions on <code>TransparentWrapper</code> <strong>may not</strong> be overridden.</p>
</li>
</ol>
<h3 id="caveats"><a href="#caveats">Caveats</a></h3>
<p>If the wrapper imposes additional constraints upon the inner type which are
required for safety, it’s responsible for ensuring those still hold – this
generally requires preventing access to instances of the inner type, as
implementing <code>TransparentWrapper&lt;U&gt; for T</code> means anybody can call
<code>T::cast_ref(any_instance_of_u)</code>.</p>
<p>For example, it would be invalid to implement TransparentWrapper for <code>str</code>
to implement <code>TransparentWrapper</code> around <code>[u8]</code> because of this.</p>
<h2 id="examples"><a href="#examples">Examples</a></h2><h3 id="basic"><a href="#basic">Basic</a></h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytemuck::TransparentWrapper;
<span class="attribute">#[repr(transparent)]
</span><span class="kw">struct </span>MyWrapper(SomeStruct);
<span class="kw">unsafe impl </span>TransparentWrapper&lt;SomeStruct&gt; <span class="kw">for </span>MyWrapper {}
<span class="comment">// interpret a reference to &amp;SomeStruct as a &amp;MyWrapper
</span><span class="kw">let </span>thing = SomeStruct::default();
<span class="kw">let </span>inner_ref: <span class="kw-2">&amp;</span>MyWrapper = MyWrapper::wrap_ref(<span class="kw-2">&amp;</span>thing);
<span class="comment">// Works with &amp;mut too.
</span><span class="kw">let </span><span class="kw-2">mut </span>mut_thing = SomeStruct::default();
<span class="kw">let </span>inner_mut: <span class="kw-2">&amp;mut </span>MyWrapper = MyWrapper::wrap_mut(<span class="kw-2">&amp;mut </span>mut_thing);
</code></pre></div>
<h3 id="use-with-dynamically-sized-types"><a href="#use-with-dynamically-sized-types">Use with dynamically sized types</a></h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytemuck::TransparentWrapper;
<span class="attribute">#[repr(transparent)]
</span><span class="kw">struct </span>Slice&lt;T&gt;([T]);
<span class="kw">unsafe impl</span>&lt;T&gt; TransparentWrapper&lt;[T]&gt; <span class="kw">for </span>Slice&lt;T&gt; {}
<span class="kw">let </span>s = Slice::wrap_ref(<span class="kw-2">&amp;</span>[<span class="number">1u32</span>, <span class="number">2</span>, <span class="number">3</span>]);
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;</span>s.<span class="number">0</span>, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);
<span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3u8</span>];
<span class="kw">let </span>sm = Slice::wrap_mut(<span class="kw-2">&amp;mut </span>buf);</code></pre></div>
<h3 id="deriving"><a href="#deriving">Deriving</a></h3>
<p>When deriving, the non-wrapped fields must uphold all the normal requirements,
and must also be <code>Zeroable</code>.</p>
<div class="example-wrap ignore"><div class='tooltip'></div><pre class="rust rust-example-rendered"><code><span class="comment">// This example requires the `derive` feature.
</span><span class="kw">use </span>bytemuck::TransparentWrapper;
<span class="kw">use </span>std::marker::PhantomData;
<span class="attribute">#[derive(TransparentWrapper)]
#[repr(transparent)]
#[transparent(usize)]
</span><span class="kw">struct </span>Wrapper&lt;T: <span class="question-mark">?</span>Sized&gt;(usize, PhantomData&lt;T&gt;); <span class="comment">// PhantomData&lt;T&gt; implements Zeroable for all T</span></code></pre></div>
<p>Here, an error will occur, because <code>MyZst</code> does not implement <code>Zeroable</code>.</p>
<div class="example-wrap ignore"><div class='tooltip'></div><pre class="rust rust-example-rendered"><code><span class="comment">// This example requires the `derive` feature.
</span><span class="kw">use </span>bytemuck::TransparentWrapper;
<span class="kw">struct </span>MyZst;
<span class="attribute">#[derive(TransparentWrapper)]
#[repr(transparent)]
#[transparent(usize)]
</span><span class="kw">struct </span>Wrapper(usize, MyZst); <span class="comment">// MyZst does not implement Zeroable</span></code></pre></div>
</div></details><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.wrap" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#129-137">source</a><h4 class="code-header">fn <a href="#method.wrap" class="fnname">wrap</a>(s: Inner) -&gt; Self<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class="docblock"><p>Convert the inner type into the wrapper type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.wrap_ref" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#142-155">source</a><h4 class="code-header">fn <a href="#method.wrap_ref" class="fnname">wrap_ref</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Inner) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Self</h4></section></summary><div class="docblock"><p>Convert a reference to the inner type into a reference to the wrapper
type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.wrap_mut" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#160-173">source</a><h4 class="code-header">fn <a href="#method.wrap_mut" class="fnname">wrap_mut</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Inner) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Self</h4></section></summary><div class="docblock"><p>Convert a mutable reference to the inner type into a mutable reference to
the wrapper type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.wrap_slice" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#177-189">source</a><h4 class="code-header">fn <a href="#method.wrap_slice" class="fnname">wrap_slice</a>(s: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a>) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a><span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class="docblock"><p>Convert a slice to the inner type into a slice to the wrapper type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.wrap_slice_mut" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#194-206">source</a><h4 class="code-header">fn <a href="#method.wrap_slice_mut" class="fnname">wrap_slice_mut</a>(s: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a><span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class="docblock"><p>Convert a mutable slice to the inner type into a mutable slice to the
wrapper type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peel" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#210-216">source</a><h4 class="code-header">fn <a href="#method.peel" class="fnname">peel</a>(s: Self) -&gt; Inner<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class="docblock"><p>Convert the wrapper type into the inner type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peel_ref" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#221-234">source</a><h4 class="code-header">fn <a href="#method.peel_ref" class="fnname">peel_ref</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;</a>Inner</h4></section></summary><div class="docblock"><p>Convert a reference to the wrapper type into a reference to the inner
type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peel_mut" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#239-252">source</a><h4 class="code-header">fn <a href="#method.peel_mut" class="fnname">peel_mut</a>(s: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&amp;mut </a>Inner</h4></section></summary><div class="docblock"><p>Convert a mutable reference to the wrapper type into a mutable reference
to the inner type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peel_slice" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#256-268">source</a><h4 class="code-header">fn <a href="#method.peel_slice" class="fnname">peel_slice</a>(s: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a>) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a><span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class="docblock"><p>Convert a slice to the wrapped type into a slice to the inner type.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peel_slice_mut" class="method has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#273-285">source</a><h4 class="code-header">fn <a href="#method.peel_slice_mut" class="fnname">peel_slice_mut</a>(s: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a>) -&gt; &amp;mut <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Inner]</a><span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class="docblock"><p>Convert a mutable slice to the wrapped type into a mutable slice to the
inner type.</p>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><section id="impl-TransparentWrapper%3CT%3E-for-Wrapping%3CT%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bytemuck/transparent.rs.html#288">source</a><a href="#impl-TransparentWrapper%3CT%3E-for-Wrapping%3CT%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.TransparentWrapper.html" title="trait bytemuck::TransparentWrapper">TransparentWrapper</a>&lt;T&gt; for <a class="struct" href="https://doc.rust-lang.org/nightly/core/num/wrapping/struct.Wrapping.html" title="struct core::num::wrapping::Wrapping">Wrapping</a>&lt;T&gt;</h3></section><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"></div><script src="../implementors/bytemuck/transparent/trait.TransparentWrapper.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="bytemuck" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>