rtic/2/api/heapless/c_string/struct.CString.html
github-merge-queue[bot] e04fb16c1b deploy: bbc37ca3fe
2025-11-12 19:06:49 +00:00

199 lines
No EOL
80 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 fixed capacity `CString`."><title>CString in heapless::c_string - 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-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="heapless" data-themes="" data-resource-suffix="" data-rustdoc-version="1.91.1 (ed61e7d7e 2025-11-07)" data-channel="1.91.1" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-c3e638e9.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-6dc2a7f3.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 struct"><!--[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="#">CString</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../heapless/index.html">heapless</a><span class="version">0.9.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">CString</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.as_bytes" title="as_bytes">as_bytes</a></li><li><a href="#method.as_bytes_with_nul" title="as_bytes_with_nul">as_bytes_with_nul</a></li><li><a href="#method.as_c_str" title="as_c_str">as_c_str</a></li><li><a href="#method.extend_from_bytes" title="extend_from_bytes">extend_from_bytes</a></li><li><a href="#method.from_bytes_with_nul" title="from_bytes_with_nul">from_bytes_with_nul</a></li><li><a href="#method.from_bytes_with_nul_unchecked" title="from_bytes_with_nul_unchecked">from_bytes_with_nul_unchecked</a></li><li><a href="#method.from_raw" title="from_raw">from_raw</a></li><li><a href="#method.new" title="new">new</a></li></ul><h3><a href="#deref-methods-CStr">Methods from Deref&lt;<wbr>Target=C<wbr>Str&gt;</a></h3><ul class="block deref-methods"><li><a href="#method.as_ptr" title="as_ptr">as_ptr</a></li><li><a href="#method.bytes" title="bytes">bytes</a></li><li><a href="#method.count_bytes" title="count_bytes">count_bytes</a></li><li><a href="#method.display" title="display">display</a></li><li><a href="#method.is_empty" title="is_empty">is_empty</a></li><li><a href="#method.to_bytes" title="to_bytes">to_bytes</a></li><li><a href="#method.to_bytes_with_nul" title="to_bytes_with_nul">to_bytes_with_nul</a></li><li><a href="#method.to_str" title="to_str">to_str</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-AsRef%3CCStr%3E-for-CString%3CN,+LenT%3E" title="AsRef&#60;CStr&#62;">AsRef&#60;CStr&#62;</a></li><li><a href="#impl-Borrow%3CCStr%3E-for-CString%3CN,+LenT%3E" title="Borrow&#60;CStr&#62;">Borrow&#60;CStr&#62;</a></li><li><a href="#impl-Clone-for-CString%3CN,+LenT%3E" title="Clone">Clone</a></li><li><a href="#impl-Debug-for-CString%3CN,+LenT%3E" title="Debug">Debug</a></li><li><a href="#impl-Default-for-CString%3CN,+LenT%3E" title="Default">Default</a></li><li><a href="#impl-Deref-for-CString%3CN,+LenT%3E" title="Deref">Deref</a></li><li><a href="#impl-Eq-for-CString%3CN,+LenT%3E" title="Eq">Eq</a></li><li><a href="#impl-Hash-for-CString%3CN,+LenT%3E" title="Hash">Hash</a></li><li><a href="#impl-Ord-for-CString%3CN,+LenT%3E" title="Ord">Ord</a></li><li><a href="#impl-PartialEq%3CCString%3CM,+LenT2%3E%3E-for-CString%3CN,+LenT1%3E" title="PartialEq&#60;CString&#60;M, LenT2&#62;&#62;">PartialEq&#60;CString&#60;M, LenT2&#62;&#62;</a></li><li><a href="#impl-PartialOrd%3CCString%3CM,+LenT2%3E%3E-for-CString%3CN,+LenT1%3E" title="PartialOrd&#60;CString&#60;M, LenT2&#62;&#62;">PartialOrd&#60;CString&#60;M, LenT2&#62;&#62;</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-CString%3CN,+LenT%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-CString%3CN,+LenT%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-CString%3CN,+LenT%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-CString%3CN,+LenT%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-CString%3CN,+LenT%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-CString%3CN,+LenT%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-CloneToUninit-for-T" title="CloneToUninit">CloneToUninit</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-Receiver-for-P" title="Receiver">Receiver</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In heapless::<wbr>c_<wbr>string</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">heapless</a>::<wbr><a href="index.html">c_string</a></div><h1>Struct <span class="struct">CString</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/heapless/c_string.rs.html#20-22">Source</a> </span></div><pre class="rust item-decl"><code>pub struct CString&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a> = <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>&gt; { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A fixed capacity <a href="https://doc.rust-lang.org/std/ffi/struct.CString.html"><code>CString</code></a>.</p>
<p>It stores up to <code>N - 1</code> non-nul characters with a trailing nul terminator.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#38-284">Source</a><a href="#impl-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#51-62">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Creates a new C-compatible string with a terminating nul byte.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>heapless::CString;
<span class="comment">// A fixed-size `CString` that can store up to 10 characters
// including the nul terminator.
</span><span class="kw">let </span>empty = CString::&lt;<span class="number">10</span>&gt;::new();
<span class="macro">assert_eq!</span>(empty.as_c_str(), <span class="string">c""</span>);
<span class="macro">assert_eq!</span>(empty.to_str(), <span class="prelude-val">Ok</span>(<span class="string">""</span>));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.from_bytes_with_nul_unchecked" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#84-90">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.from_bytes_with_nul_unchecked" class="fn">from_bytes_with_nul_unchecked</a>(
bytes: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, <a class="struct" href="../struct.CapacityError.html" title="struct heapless::CapacityError">CapacityError</a>&gt;</h4></section></summary><div class="docblock"><p>Unsafely creates a <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> from a byte slice.</p>
<p>This function will copy the provided <code>bytes</code> to a <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> without
performing any sanity checks.</p>
<p>The function will fail if <code>bytes.len() &gt; N</code>.</p>
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
<p>The provided slice <strong>must</strong> be nul-terminated and not contain any interior
nul bytes.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>heapless::CString;
<span class="kw">let </span><span class="kw-2">mut </span>c_string = <span class="kw">unsafe </span>{ CString::&lt;<span class="number">7</span>&gt;::from_bytes_with_nul_unchecked(<span class="string">b"string\0"</span>).unwrap() };
<span class="macro">assert_eq!</span>(c_string.to_str(), <span class="prelude-val">Ok</span>(<span class="string">"string"</span>));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.from_bytes_with_nul" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#97-103">Source</a><h4 class="code-header">pub fn <a href="#method.from_bytes_with_nul" class="fn">from_bytes_with_nul</a>(bytes: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, <a class="enum" href="enum.ExtendError.html" title="enum heapless::c_string::ExtendError">ExtendError</a>&gt;</h4></section></summary><div class="docblock"><p>Instantiates a <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> copying from the giving byte slice, assuming it is
nul-terminated.</p>
<p>Fails if the given byte slice has any interior nul byte, if the slice does not
end with a nul byte, or if the byte slice cant fit in <code>N</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_raw" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#132-135">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.from_raw" class="fn">from_raw</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.pointer.html">*const </a><a class="type" href="https://doc.rust-lang.org/1.91.1/core/ffi/primitives/type.c_char.html" title="type core::ffi::primitives::c_char">c_char</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, <a class="enum" href="enum.ExtendError.html" title="enum heapless::c_string::ExtendError">ExtendError</a>&gt;</h4></section></summary><div class="docblock"><p>Builds a <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> copying from a raw C string pointer.</p>
<h5 id="safety-1"><a class="doc-anchor" href="#safety-1">§</a>Safety</h5>
<ul>
<li>The memory pointed to by <code>ptr</code> must contain a valid nul terminator at the end of the
string.</li>
<li><code>ptr</code> must be valid for reads of bytes up to and including the nul terminator. This means
in particular:
<ul>
<li>The entire memory range of this <code>CStr</code> must be contained within a single allocated
object!</li>
<li><code>ptr</code> must be non-nul even for a zero-length <code>CStr</code>.</li>
</ul>
</li>
</ul>
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>core::ffi::{c_char, CStr};
<span class="kw">use </span>heapless::CString;
<span class="kw">const </span>HELLO_PTR: <span class="kw-2">*const </span>c_char = {
<span class="kw">const </span>BYTES: <span class="kw-2">&amp;</span>[u8] = <span class="string">b"Hello, world!\0"</span>;
BYTES.as_ptr().cast()
};
<span class="kw">let </span>copied = <span class="kw">unsafe </span>{ CString::&lt;<span class="number">14</span>&gt;::from_raw(HELLO_PTR) }.unwrap();
<span class="macro">assert_eq!</span>(copied.to_str(), <span class="prelude-val">Ok</span>(<span class="string">"Hello, world!"</span>));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.as_c_str" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#139-141">Source</a><h4 class="code-header">pub fn <a href="#method.as_c_str" class="fn">as_c_str</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a></h4></section></summary><div class="docblock"><p>Converts the <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> to a <a href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr"><code>CStr</code></a> slice.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.extend_from_bytes" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#182-219">Source</a><h4 class="code-header">pub fn <a href="#method.extend_from_bytes" class="fn">extend_from_bytes</a>(&amp;mut self, bytes: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.unit.html">()</a>, <a class="enum" href="enum.ExtendError.html" title="enum heapless::c_string::ExtendError">ExtendError</a>&gt;</h4></section></summary><div class="docblock"><p>Extends the <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> with the given bytes.</p>
<p>This function fails if the <a href="struct.CString.html" title="struct heapless::c_string::CString"><code>CString</code></a> would not have enough capacity to append the bytes or
if the bytes contain an interior nul byte.</p>
<h5 id="example-1"><a class="doc-anchor" href="#example-1">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>heapless::CString;
<span class="kw">let </span><span class="kw-2">mut </span>c_string = CString::&lt;<span class="number">10</span>&gt;::new();
c_string.extend_from_bytes(<span class="string">b"hey"</span>).unwrap();
c_string.extend_from_bytes(<span class="string">b" there\0"</span>).unwrap();
<span class="macro">assert_eq!</span>(c_string.to_str(), <span class="prelude-val">Ok</span>(<span class="string">"hey there"</span>));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.as_bytes_with_nul" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#264-266">Source</a><h4 class="code-header">pub fn <a href="#method.as_bytes_with_nul" class="fn">as_bytes_with_nul</a>(&amp;self) -&gt; &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>]</h4></section></summary><div class="docblock"><p>Returns the underlying byte slice including the trailing nul terminator.</p>
<h5 id="example-2"><a class="doc-anchor" href="#example-2">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>heapless::CString;
<span class="kw">let </span><span class="kw-2">mut </span>c_string = CString::&lt;<span class="number">5</span>&gt;::new();
c_string.extend_from_bytes(<span class="string">b"abc"</span>).unwrap();
<span class="macro">assert_eq!</span>(c_string.as_bytes_with_nul(), <span class="string">b"abc\0"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.as_bytes" class="method"><a class="src rightside" href="../../src/heapless/c_string.rs.html#281-283">Source</a><h4 class="code-header">pub fn <a href="#method.as_bytes" class="fn">as_bytes</a>(&amp;self) -&gt; &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>]</h4></section></summary><div class="docblock"><p>Returns the underlying byte slice excluding the trailing nul terminator.</p>
<h5 id="example-3"><a class="doc-anchor" href="#example-3">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>heapless::CString;
<span class="kw">let </span><span class="kw-2">mut </span>c_string = CString::&lt;<span class="number">5</span>&gt;::new();
c_string.extend_from_bytes(<span class="string">b"abc"</span>).unwrap();
<span class="macro">assert_eq!</span>(c_string.as_bytes(), <span class="string">b"abc"</span>);</code></pre></div></div></details></div></details></div><details class="toggle big-toggle" open><summary><h2 id="deref-methods-CStr" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = <a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a>&gt;</span><a href="#deref-methods-CStr" class="anchor">§</a></h2></summary><div id="deref-methods-CStr-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_ptr" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#485">Source</a></span><h4 class="code-header">pub fn <a href="#method.as_ptr" class="fn">as_ptr</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.pointer.html">*const </a><a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.i8.html">i8</a></h4></section></summary><div class="docblock"><p>Returns the inner pointer to this C string.</p>
<p>The returned pointer will be valid for as long as <code>self</code> is, and points
to a contiguous region of memory terminated with a 0 byte to represent
the end of the string.</p>
<p>The type of the returned pointer is
<a href="https://doc.rust-lang.org/1.91.1/core/ffi/primitives/type.c_char.html" title="type core::ffi::primitives::c_char"><code>*const c_char</code></a>, and whether its
an alias for <code>*const i8</code> or <code>*const u8</code> is platform-specific.</p>
<p><strong>WARNING</strong></p>
<p>The returned pointer is read-only; writing to it (including passing it
to C code that writes to it) causes undefined behavior.</p>
<p>It is your responsibility to make sure that the underlying memory is not
freed too early. For example, the following code will cause undefined
behavior when <code>ptr</code> is used inside the <code>unsafe</code> block:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::{CStr, CString};
<span class="comment">// 💀 The meaning of this entire program is undefined,
// 💀 and nothing about its behavior is guaranteed,
// 💀 not even that its behavior resembles the code as written,
// 💀 just because it contains a single instance of undefined behavior!
// 🚨 creates a dangling pointer to a temporary `CString`
// 🚨 that is deallocated at the end of the statement
</span><span class="kw">let </span>ptr = CString::new(<span class="string">"Hi!"</span>.to_uppercase()).unwrap().as_ptr();
<span class="comment">// without undefined behavior, you would expect that `ptr` equals:
</span><span class="macro">dbg!</span>(CStr::from_bytes_with_nul(<span class="string">b"HI!\0"</span>).unwrap());
<span class="comment">// 🙏 Possibly the program behaved as expected so far,
// 🙏 and this just shows `ptr` is now garbage..., but
// 💀 this violates `CStr::from_ptr`'s safety contract
// 💀 leading to a dereference of a dangling pointer,
// 💀 which is immediate undefined behavior.
// 💀 *BOOM*, you're dead, your entire program has no meaning.
</span><span class="macro">dbg!</span>(<span class="kw">unsafe </span>{ CStr::from_ptr(ptr) });</code></pre></div>
<p>This happens because, the pointer returned by <code>as_ptr</code> does not carry any
lifetime information, and the <code>CString</code> is deallocated immediately after
the expression that it is part of has been evaluated.
To fix the problem, bind the <code>CString</code> to a local variable:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::{CStr, CString};
<span class="kw">let </span>c_str = CString::new(<span class="string">"Hi!"</span>.to_uppercase()).unwrap();
<span class="kw">let </span>ptr = c_str.as_ptr();
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ CStr::from_ptr(ptr) }, <span class="string">c"HI!"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.count_bytes" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.79.0">1.79.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#516">Source</a></span><h4 class="code-header">pub fn <a href="#method.count_bytes" class="fn">count_bytes</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Returns the length of <code>self</code>. Like Cs <code>strlen</code>, this does not include the nul terminator.</p>
<blockquote>
<p><strong>Note</strong>: This method is currently implemented as a constant-time
cast, but it is planned to alter its definition in the future to
perform the length calculation whenever this method is called.</p>
</blockquote>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="string">c"foo"</span>.count_bytes(), <span class="number">3</span>);
<span class="macro">assert_eq!</span>(<span class="string">c""</span>.count_bytes(), <span class="number">0</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.is_empty" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.71.0">1.71.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#531">Source</a></span><h4 class="code-header">pub fn <a href="#method.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>self.to_bytes()</code> has a length of 0.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert!</span>(!<span class="string">c"foo"</span>.is_empty());
<span class="macro">assert!</span>(<span class="string">c""</span>.is_empty());</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.to_bytes" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#557">Source</a></span><h4 class="code-header">pub fn <a href="#method.to_bytes" class="fn">to_bytes</a>(&amp;self) -&gt; &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>]</h4></section></summary><div class="docblock"><p>Converts this C string to a byte slice.</p>
<p>The returned slice will <strong>not</strong> contain the trailing nul terminator that this C
string has.</p>
<blockquote>
<p><strong>Note</strong>: This method is currently implemented as a constant-time
cast, but it is planned to alter its definition in the future to
perform the length calculation whenever this method is called.</p>
</blockquote>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="string">c"foo"</span>.to_bytes(), <span class="string">b"foo"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.to_bytes_with_nul" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#583">Source</a></span><h4 class="code-header">pub fn <a href="#method.to_bytes_with_nul" class="fn">to_bytes_with_nul</a>(&amp;self) -&gt; &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>]</h4></section></summary><div class="docblock"><p>Converts this C string to a byte slice containing the trailing 0 byte.</p>
<p>This function is the equivalent of <a href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html#method.to_bytes" title="method core::ffi::c_str::CStr::to_bytes"><code>CStr::to_bytes</code></a> except that it
will retain the trailing nul terminator instead of chopping it off.</p>
<blockquote>
<p><strong>Note</strong>: This method is currently implemented as a 0-cost cast, but
it is planned to alter its definition in the future to perform the
length calculation whenever this method is called.</p>
</blockquote>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="string">c"foo"</span>.to_bytes_with_nul(), <span class="string">b"foo\0"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.bytes" class="method"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#603">Source</a><h4 class="code-header">pub fn <a href="#method.bytes" class="fn">bytes</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.Bytes.html" title="struct core::ffi::c_str::Bytes">Bytes</a>&lt;'_&gt;</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>cstr_bytes</code>)</span></div></span></summary><div class="docblock"><p>Iterates over the bytes in this C string.</p>
<p>The returned iterator will <strong>not</strong> contain the trailing nul terminator
that this C string has.</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#![feature(cstr_bytes)]
</span><span class="macro">assert!</span>(<span class="string">c"foo"</span>.bytes().eq(<span class="kw-2">*</span><span class="string">b"foo"</span>));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.to_str" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.4.0">1.4.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#622">Source</a></span><h4 class="code-header">pub fn <a href="#method.to_str" class="fn">to_str</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.91.1/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>&gt;</h4></section></summary><div class="docblock"><p>Yields a <code>&amp;<a href="https://doc.rust-lang.org/1.91.1/core/primitive.str.html" title="str">str</a></code> slice if the <code>CStr</code> contains valid UTF-8.</p>
<p>If the contents of the <code>CStr</code> are valid UTF-8 data, this
function will return the corresponding <code>&amp;<a href="https://doc.rust-lang.org/1.91.1/core/primitive.str.html" title="str">str</a></code> slice. Otherwise,
it will return an error with details of where UTF-8 validation failed.</p>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="string">c"foo"</span>.to_str(), <span class="prelude-val">Ok</span>(<span class="string">"foo"</span>));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.display" class="method"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/ffi/c_str.rs.html#650">Source</a><h4 class="code-header">pub fn <a href="#method.display" class="fn">display</a>(&amp;self) -&gt; impl <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>cstr_display</code>)</span></div></span></summary><div class="docblock"><p>Returns an object that implements <a href="https://doc.rust-lang.org/1.91.1/core/fmt/trait.Display.html" title="trait core::fmt::Display"><code>Display</code></a> for safely printing a <a href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr"><code>CStr</code></a> that may
contain non-Unicode data.</p>
<p>Behaves as if <code>self</code> were first lossily converted to a <code>str</code>, with invalid UTF-8 presented
as the Unicode replacement character: <20>.</p>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#![feature(cstr_display)]
</span><span class="kw">let </span>cstr = <span class="string">c"Hello, world!"</span>;
<span class="macro">println!</span>(<span class="string">"{}"</span>, cstr.display());</code></pre></div></div></details></div></details><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-AsRef%3CCStr%3E-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#286-291">Source</a><a href="#impl-AsRef%3CCStr%3E-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a>&gt; for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_ref" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#288-290">Source</a><a href="#method.as_ref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.AsRef.html#tymethod.as_ref" class="fn">as_ref</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a></h4></section></summary><div class='docblock'>Converts this type into a shared reference of the (usually inferred) input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Borrow%3CCStr%3E-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#293-298">Source</a><a href="#impl-Borrow%3CCStr%3E-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a>&gt; for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#295-297">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#19">Source</a><a href="#impl-Clone-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#19">Source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&amp;self) -&gt; <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h4></section></summary><div class='docblock'>Returns a duplicate of the value. <a href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/clone.rs.html#245-247">Source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&amp;mut self, source: &amp;Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#343-347">Source</a><a href="#impl-Debug-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#344-346">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.91.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.91.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.91.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#300-305">Source</a><a href="#impl-Default-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#302-304">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -&gt; Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.91.1/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deref-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#307-314">Source</a><a href="#impl-Deref-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Target" class="associatedtype trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#308">Source</a><a href="#associatedtype.Target" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Deref.html#associatedtype.Target" class="associatedtype">Target</a> = <a class="struct" href="https://doc.rust-lang.org/1.91.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a></h4></section></summary><div class='docblock'>The resulting type after dereferencing.</div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#311-313">Source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Deref.html#tymethod.deref" class="fn">deref</a>(&amp;self) -&gt; &amp;Self::<a class="associatedtype" href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a></h4></section></summary><div class='docblock'>Dereferences the value.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Hash-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#19">Source</a><a href="#impl-Hash-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#19">Source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a>&lt;__H: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>&gt;(&amp;self, state: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;mut __H</a>)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/hash/mod.rs.html#235-237">Source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a>&lt;H&gt;(data: &amp;[Self], state: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;mut H</a>)<div class="where">where
H: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.91.1/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Ord-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#336-341">Source</a><a href="#impl-Ord-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#338-340">Source</a><a href="#method.cmp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#tymethod.cmp" class="fn">cmp</a>(&amp;self, rhs: &amp;Self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></h4></section></summary><div class='docblock'>This method returns an <a href="https://doc.rust-lang.org/1.91.1/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering"><code>Ordering</code></a> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.max" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1023-1025">Source</a></span><a href="#method.max" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#method.max" class="fn">max</a>(self, other: Self) -&gt; Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#method.max">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.min" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1062-1064">Source</a></span><a href="#method.min" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#method.min" class="fn">min</a>(self, other: Self) -&gt; Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#method.min">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.50.0">1.50.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1088-1090">Source</a></span><a href="#method.clamp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#method.clamp" class="fn">clamp</a>(self, min: Self, max: Self) -&gt; Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Restrict a value to a certain interval. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Ord.html#method.clamp">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CCString%3CM,+LenT2%3E%3E-for-CString%3CN,+LenT1%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#316-323">Source</a><a href="#impl-PartialEq%3CCString%3CM,+LenT2%3E%3E-for-CString%3CN,+LenT1%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, const M: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT1: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>, LenT2: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;M, LenT2&gt;&gt; for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT1&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#320-322">Source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&amp;self, rhs: &amp;<a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;M, LenT2&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#264">Source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>!=</code>. The default implementation is almost always sufficient,
and should not be overridden without very good reason.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CCString%3CM,+LenT2%3E%3E-for-CString%3CN,+LenT1%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#327-334">Source</a><a href="#impl-PartialOrd%3CCString%3CM,+LenT2%3E%3E-for-CString%3CN,+LenT1%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, const M: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT1: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>, LenT2: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;<a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;M, LenT2&gt;&gt; for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT1&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#331-333">Source</a><a href="#method.partial_cmp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp" class="fn">partial_cmp</a>(&amp;self, rhs: &amp;<a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;M, LenT2&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.91.1/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>&gt;</h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1399">Source</a></span><a href="#method.lt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.lt" class="fn">lt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests less than (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;</code> operator. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.le" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1417">Source</a></span><a href="#method.le" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.le" class="fn">le</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the
<code>&lt;=</code> operator. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.le">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1435">Source</a></span><a href="#method.gt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.gt" class="fn">gt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;</code>
operator. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.91.1/src/core/cmp.rs.html#1453">Source</a></span><a href="#method.ge" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.ge" class="fn">ge</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by
the <code>&gt;=</code> operator. <a href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></div></details></div></details><section id="impl-Eq-for-CString%3CN,+LenT%3E" class="impl"><a class="src rightside" href="../../src/heapless/c_string.rs.html#325">Source</a><a href="#impl-Eq-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT: <a class="trait" href="../trait.LenType.html" title="trait heapless::LenType">LenType</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-CString%3CN,+LenT%3E" class="impl"><a href="#impl-Freeze-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;<div class="where">where
LenT: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a>,</div></h3></section><section id="impl-RefUnwindSafe-for-CString%3CN,+LenT%3E" class="impl"><a href="#impl-RefUnwindSafe-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;<div class="where">where
LenT: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a>,</div></h3></section><section id="impl-Send-for-CString%3CN,+LenT%3E" class="impl"><a href="#impl-Send-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section><section id="impl-Sync-for-CString%3CN,+LenT%3E" class="impl"><a href="#impl-Sync-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;</h3></section><section id="impl-Unpin-for-CString%3CN,+LenT%3E" class="impl"><a href="#impl-Unpin-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;<div class="where">where
LenT: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-CString%3CN,+LenT%3E" class="impl"><a href="#impl-UnwindSafe-for-CString%3CN,+LenT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;const N: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.usize.html">usize</a>, LenT&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.CString.html" title="struct heapless::c_string::CString">CString</a>&lt;N, LenT&gt;<div class="where">where
LenT: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,</div></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.91.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.91.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.91.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CloneToUninit-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/clone.rs.html#515">Source</a><a href="#impl-CloneToUninit-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/clone/trait.CloneToUninit.html" title="trait core::clone::CloneToUninit">CloneToUninit</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone_to_uninit" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/clone.rs.html#517">Source</a><a href="#method.clone_to_uninit" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.91.1/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit" class="fn">clone_to_uninit</a>(&amp;self, dest: <a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.pointer.html">*mut </a><a class="primitive" href="https://doc.rust-lang.org/1.91.1/core/primitive.u8.html">u8</a>)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>clone_to_uninit</code>)</span></div></span><div class='docblock'>Performs copy-assignment from <code>self</code> to <code>dest</code>. <a href="https://doc.rust-lang.org/1.91.1/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Receiver-for-P" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/ops/deref.rs.html#378-380">Source</a><a href="#impl-Receiver-for-P" class="anchor">§</a><h3 class="code-header">impl&lt;P, T&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Receiver.html" title="trait core::ops::deref::Receiver">Receiver</a> for P<div class="where">where
P: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = T&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
T: ?<a class="trait" href="https://doc.rust-lang.org/1.91.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Target-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/ops/deref.rs.html#382">Source</a><a href="#associatedtype.Target-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.91.1/core/ops/deref/trait.Receiver.html#associatedtype.Target" class="associatedtype">Target</a> = T</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>arbitrary_self_types</code>)</span></div></span><div class='docblock'>The target type on which the method may be called.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.91.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.91.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.91.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>