Files
GopherGate/target/doc/bytemuck/checked/trait.CheckedBitPattern.html
2026-02-26 12:00:21 -05:00

98 lines
39 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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 marker trait that allows types that have some invalid bit patterns to be used in places that otherwise require `AnyBitPattern` or `Pod` types by performing a runtime check on a perticular set of bits. This is particularly useful for types like fieldless (C-style) enums, `char`, bool, and structs containing them."><title>CheckedBitPattern in bytemuck::checked - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="bytemuck" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">CheckedBitPattern</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../bytemuck/index.html">bytemuck</a><span class="version">1.25.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Checked<wbr>BitPattern</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#derive" title="Derive">Derive</a></li><li><a href="#example" title="Example">Example</a></li><li><a href="#safety" title="Safety">Safety</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Bits" title="Bits">Bits</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.is_valid_bit_pattern" title="is_valid_bit_pattern">is_valid_bit_pattern</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-CheckedBitPattern-for-NonZero%3Ci8%3E" title="NonZeroI8">NonZeroI8</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Ci16%3E" title="NonZeroI16">NonZeroI16</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Ci32%3E" title="NonZeroI32">NonZeroI32</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Ci64%3E" title="NonZeroI64">NonZeroI64</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Ci128%3E" title="NonZeroI128">NonZeroI128</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cisize%3E" title="NonZeroIsize">NonZeroIsize</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cu8%3E" title="NonZeroU8">NonZeroU8</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cu16%3E" title="NonZeroU16">NonZeroU16</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cu32%3E" title="NonZeroU32">NonZeroU32</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cu64%3E" title="NonZeroU64">NonZeroU64</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cu128%3E" title="NonZeroU128">NonZeroU128</a></li><li><a href="#impl-CheckedBitPattern-for-NonZero%3Cusize%3E" title="NonZeroUsize">NonZeroUsize</a></li><li><a href="#impl-CheckedBitPattern-for-bool" title="bool">bool</a></li><li><a href="#impl-CheckedBitPattern-for-char" title="char">char</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bytemuck::<wbr>checked</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">bytemuck</a>::<wbr><a href="index.html">checked</a></div><h1>Trait <span class="trait">Checked<wbr>BitPattern</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/bytemuck/checked.rs.html#130-141">Source</a> </span></div><pre class="rust item-decl"><code>pub unsafe trait CheckedBitPattern: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> {
type <a href="#associatedtype.Bits" class="associatedtype">Bits</a>: <a class="trait" href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern">AnyBitPattern</a>;
// Required method
fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A marker trait that allows types that have some invalid bit patterns to be
used in places that otherwise require <a href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern"><code>AnyBitPattern</code></a> or <a href="../trait.Pod.html" title="trait bytemuck::Pod"><code>Pod</code></a> types by
performing a runtime check on a perticular set of bits. This is particularly
useful for types like fieldless (C-style) enums, <a href="https://doc.rust-lang.org/1.93.1/core/primitive.char.html" title="primitive char"><code>char</code></a>, bool, and
structs containing them.</p>
<p>To do this, we define a <code>Bits</code> type which is a type with equivalent layout
to <code>Self</code> other than the invalid bit patterns which disallow <code>Self</code> from
being <a href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern"><code>AnyBitPattern</code></a>. This <code>Bits</code> type must itself implement
<a href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern"><code>AnyBitPattern</code></a>. Then, we implement a function that checks whether a
certain instance of the <code>Bits</code> is also a valid bit pattern of <code>Self</code>. If
this check passes, then we can allow casting from the <code>Bits</code> to <code>Self</code> (and
therefore, any type which is able to be cast to <code>Bits</code> is also able to be
cast to <code>Self</code>).</p>
<p><a href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern"><code>AnyBitPattern</code></a> is a subset of <a href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern"><code>CheckedBitPattern</code></a>, meaning that any <code>T: AnyBitPattern</code> is also <a href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern"><code>CheckedBitPattern</code></a>. This means you can also use
any <a href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern"><code>AnyBitPattern</code></a> type in the checked versions of casting functions in
this module. If its possible, prefer implementing <a href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern"><code>AnyBitPattern</code></a> for
your type directly instead of <a href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern"><code>CheckedBitPattern</code></a> as it gives greater
flexibility.</p>
<h2 id="derive"><a class="doc-anchor" href="#derive">§</a>Derive</h2>
<p>A <code>#[derive(CheckedBitPattern)]</code> macro is provided under the <code>derive</code>
feature flag which will automatically validate the requirements of this
trait and implement the trait for you for both enums and structs. This is
the recommended method for implementing the trait, however its also
possible to do manually.</p>
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
<p>If manually implementing the trait, we can do something like so:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytemuck::{CheckedBitPattern, NoUninit};
<span class="attr">#[repr(u32)]
#[derive(Copy, Clone)]
</span><span class="kw">enum </span>MyEnum {
Variant0 = <span class="number">0</span>,
Variant1 = <span class="number">1</span>,
Variant2 = <span class="number">2</span>,
}
<span class="kw">unsafe impl </span>CheckedBitPattern <span class="kw">for </span>MyEnum {
<span class="kw">type </span>Bits = u32;
<span class="kw">fn </span>is_valid_bit_pattern(bits: <span class="kw-2">&amp;</span>u32) -&gt; bool {
<span class="kw">match </span><span class="kw-2">*</span>bits {
<span class="number">0 </span>| <span class="number">1 </span>| <span class="number">2 </span>=&gt; <span class="bool-val">true</span>,
<span class="kw">_ </span>=&gt; <span class="bool-val">false</span>,
}
}
}
<span class="comment">// It is often useful to also implement `NoUninit` on our `CheckedBitPattern` types.
// This will allow us to do casting of mutable references (and mutable slices).
// It is not always possible to do so, but in this case we have no padding so it is.
</span><span class="kw">unsafe impl </span>NoUninit <span class="kw">for </span>MyEnum {}</code></pre></div>
<p>We can now use relevant casting functions. For example,</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytemuck::{bytes_of, bytes_of_mut};
<span class="kw">use </span>bytemuck::checked;
<span class="kw">let </span>bytes = bytes_of(<span class="kw-2">&amp;</span><span class="number">2u32</span>);
<span class="kw">let </span>result = checked::try_from_bytes::&lt;MyEnum&gt;(bytes);
<span class="macro">assert_eq!</span>(result, <span class="prelude-val">Ok</span>(<span class="kw-2">&amp;</span>MyEnum::Variant2));
<span class="comment">// Fails for invalid discriminant
</span><span class="kw">let </span>bytes = bytes_of(<span class="kw-2">&amp;</span><span class="number">100u32</span>);
<span class="kw">let </span>result = checked::try_from_bytes::&lt;MyEnum&gt;(bytes);
<span class="macro">assert!</span>(result.is_err());
<span class="comment">// Since we implemented NoUninit, we can also cast mutably from an original type
// that is `NoUninit + AnyBitPattern`:
</span><span class="kw">let </span><span class="kw-2">mut </span>my_u32 = <span class="number">2u32</span>;
{
<span class="kw">let </span>as_enum_mut = checked::cast_mut::&lt;<span class="kw">_</span>, MyEnum&gt;(<span class="kw-2">&amp;mut </span>my_u32);
<span class="macro">assert_eq!</span>(as_enum_mut, <span class="kw-2">&amp;mut </span>MyEnum::Variant2);
<span class="kw-2">*</span>as_enum_mut = MyEnum::Variant0;
}
<span class="macro">assert_eq!</span>(my_u32, <span class="number">0u32</span>);</code></pre></div><h2 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h2>
<ul>
<li><code>Self</code> <em>must</em> have the same layout as the specified <code>Bits</code> except for the
possible invalid bit patterns being checked during
<a href="trait.CheckedBitPattern.html#tymethod.is_valid_bit_pattern" title="associated function bytemuck::checked::CheckedBitPattern::is_valid_bit_pattern"><code>is_valid_bit_pattern</code></a>.</li>
<li>This almost certainly means your type must be <code>#[repr(C)]</code> or a similar
specified repr, but if you think you know better, you probably dont. If
you still think you know better, be careful and have fun. And dont mess
it up (I mean it).</li>
<li>If <a href="trait.CheckedBitPattern.html#tymethod.is_valid_bit_pattern" title="associated function bytemuck::checked::CheckedBitPattern::is_valid_bit_pattern"><code>is_valid_bit_pattern</code></a> returns true, then the bit pattern contained
in <code>bits</code> must also be valid for an instance of <code>Self</code>.</li>
<li>Probably more, dont mess it up (I mean it 2.0)</li>
</ul>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Bits" class="method"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#136">Source</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a>: <a class="trait" href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern">AnyBitPattern</a></h4></section></summary><div class="docblock"><p><code>Self</code> <em>must</em> have the same layout as the specified <code>Bits</code> except for
the possible invalid bit patterns being checked during
<a href="trait.CheckedBitPattern.html#tymethod.is_valid_bit_pattern" title="associated function bytemuck::checked::CheckedBitPattern::is_valid_bit_pattern"><code>is_valid_bit_pattern</code></a>.</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.is_valid_bit_pattern" class="method"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#140">Source</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>If this function returns true, then it must be valid to reinterpret <code>bits</code>
as <code>&amp;Self</code>.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-bool" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#161-172">Source</a><a href="#impl-CheckedBitPattern-for-bool" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#162">Source</a><a href="#associatedtype.Bits-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u8.html">u8</a></h4></section><section id="method.is_valid_bit_pattern" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#165-171">Source</a><a href="#method.is_valid_bit_pattern" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-char" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#152-159">Source</a><a href="#impl-CheckedBitPattern-for-char" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.char.html">char</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-2" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#153">Source</a><a href="#associatedtype.Bits-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u32.html">u32</a></h4></section><section id="method.is_valid_bit_pattern-1" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#156-158">Source</a><a href="#method.is_valid_bit_pattern-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Ci8%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Ci8%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroI8.html" title="type core::num::nonzero::NonZeroI8">NonZeroI8</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-3" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.i8.html">i8</a></h4></section><section id="method.is_valid_bit_pattern-2" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Ci16%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Ci16%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroI16.html" title="type core::num::nonzero::NonZeroI16">NonZeroI16</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-4" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.i16.html">i16</a></h4></section><section id="method.is_valid_bit_pattern-3" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-3" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Ci32%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Ci32%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroI32.html" title="type core::num::nonzero::NonZeroI32">NonZeroI32</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-5" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-5" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.i32.html">i32</a></h4></section><section id="method.is_valid_bit_pattern-4" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-4" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Ci64%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Ci64%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroI64.html" title="type core::num::nonzero::NonZeroI64">NonZeroI64</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-6" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-6" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.i64.html">i64</a></h4></section><section id="method.is_valid_bit_pattern-5" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-5" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Ci128%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Ci128%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroI128.html" title="type core::num::nonzero::NonZeroI128">NonZeroI128</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-7" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-7" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.i128.html">i128</a></h4></section><section id="method.is_valid_bit_pattern-6" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-6" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cisize%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cisize%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroIsize.html" title="type core::num::nonzero::NonZeroIsize">NonZeroIsize</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-8" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-8" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.isize.html">isize</a></h4></section><section id="method.is_valid_bit_pattern-7" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-7" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cu8%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cu8%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU8.html" title="type core::num::nonzero::NonZeroU8">NonZeroU8</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-9" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-9" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u8.html">u8</a></h4></section><section id="method.is_valid_bit_pattern-8" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-8" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cu16%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cu16%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU16.html" title="type core::num::nonzero::NonZeroU16">NonZeroU16</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-10" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-10" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u16.html">u16</a></h4></section><section id="method.is_valid_bit_pattern-9" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-9" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cu32%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cu32%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU32.html" title="type core::num::nonzero::NonZeroU32">NonZeroU32</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-11" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-11" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u32.html">u32</a></h4></section><section id="method.is_valid_bit_pattern-10" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-10" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cu64%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cu64%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU64.html" title="type core::num::nonzero::NonZeroU64">NonZeroU64</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-12" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-12" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u64.html">u64</a></h4></section><section id="method.is_valid_bit_pattern-11" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-11" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cu128%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cu128%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU128.html" title="type core::num::nonzero::NonZeroU128">NonZeroU128</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-13" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-13" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.u128.html">u128</a></h4></section><section id="method.is_valid_bit_pattern-12" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-12" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-NonZero%3Cusize%3E" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#impl-CheckedBitPattern-for-NonZero%3Cusize%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for <a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroUsize.html" title="type core::num::nonzero::NonZeroUsize">NonZeroUsize</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-14" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#associatedtype.Bits-14" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.usize.html">usize</a></h4></section><section id="method.is_valid_bit_pattern-13" class="method trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#189-202">Source</a><a href="#method.is_valid_bit_pattern-13" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.is_valid_bit_pattern" class="fn">is_valid_bit_pattern</a>(bits: &amp;Self::<a class="associatedtype" href="trait.CheckedBitPattern.html#associatedtype.Bits" title="type bytemuck::checked::CheckedBitPattern::Bits">Bits</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-CheckedBitPattern-for-T" class="impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#143-150">Source</a><a href="#impl-CheckedBitPattern-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="../trait.AnyBitPattern.html" title="trait bytemuck::AnyBitPattern">AnyBitPattern</a>&gt; <a class="trait" href="trait.CheckedBitPattern.html" title="trait bytemuck::checked::CheckedBitPattern">CheckedBitPattern</a> for T</h3></section></summary><div class="impl-items"><section id="associatedtype.Bits-15" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bytemuck/checked.rs.html#144">Source</a><a href="#associatedtype.Bits-15" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a> = T</h4></section></div></details></div><script src="../../trait.impl/bytemuck/checked/trait.CheckedBitPattern.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html>