<!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="API documentation for the Rust `CString` struct in crate `std`."><meta name="keywords" content="rust, rustlang, rust-lang, CString"><title>std::ffi::CString - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize1.35.0.css"><link rel="stylesheet" type="text/css" href="../../rustdoc1.35.0.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark1.35.0.css"><link rel="stylesheet" type="text/css" href="../../light1.35.0.css" id="themeStyle"><script src="../../storage1.35.0.js"></script><noscript><link rel="stylesheet" href="../../noscript1.35.0.css"></noscript><link rel="shortcut icon" href="../../favicon1.35.0.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow1.35.0.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../std/index.html'><img src='../../rust-logo1.35.0.png' alt='logo' width='100'></a><p class='location'>Struct CString</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.as_bytes">as_bytes</a><a href="#method.as_bytes_with_nul">as_bytes_with_nul</a><a href="#method.as_c_str">as_c_str</a><a href="#method.from_raw">from_raw</a><a href="#method.from_vec_unchecked">from_vec_unchecked</a><a href="#method.into_boxed_c_str">into_boxed_c_str</a><a href="#method.into_bytes">into_bytes</a><a href="#method.into_bytes_with_nul">into_bytes_with_nul</a><a href="#method.into_raw">into_raw</a><a href="#method.into_string">into_string</a><a href="#method.new">new</a></div><a class="sidebar-title" href="#deref-methods">Methods from Deref<Target=CStr></a><div class="sidebar-links"><a href="#method.as_ptr">as_ptr</a><a href="#method.to_bytes">to_bytes</a><a href="#method.to_bytes_with_nul">to_bytes_with_nul</a><a href="#method.to_str">to_str</a><a href="#method.to_string_lossy">to_string_lossy</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CCStr%3E">AsRef<CStr></a><a href="#impl-Borrow%3CCStr%3E">Borrow<CStr></a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-Deref">Deref</a><a href="#impl-Drop">Drop</a><a href="#impl-Eq">Eq</a><a href="#impl-From%3C%26%27_%20CStr%3E">From<&'_ CStr></a><a href="#impl-From%3C%26%27a%20CString%3E">From<&'a CString></a><a href="#impl-From%3CBox%3CCStr%3E%3E">From<Box<CStr>></a><a href="#impl-From%3CCString%3E">From<CString></a><a href="#impl-From%3CCow%3C%27a%2C%20CStr%3E%3E">From<Cow<'a, CStr>></a><a href="#impl-Hash">Hash</a><a href="#impl-Index%3CRangeFull%3E">Index<RangeFull></a><a href="#impl-Ord">Ord</a><a href="#impl-PartialEq%3CCString%3E">PartialEq<CString></a><a href="#impl-PartialOrd%3CCString%3E">PartialOrd<CString></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow">Borrow</a><a href="#impl-BorrowMut">BorrowMut</a><a href="#impl-From">From</a><a href="#impl-Into">Into</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-TryInto">TryInto</a></div></div><p class='location'><a href='../index.html'>std</a>::<wbr><a href='index.html'>ffi</a></p><script>window.sidebarCurrent = {name: 'CString', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush1.35.0.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme1.35.0.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel1.35.0.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/std/ffi/c_str.rs.html#116-121' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='../index.html'>std</a>::<wbr><a href='index.html'>ffi</a>::<wbr><a class="struct" href=''>CString</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct CString { /* fields omitted */ }</pre></div><div class='docblock'><p>A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the middle.</p> <p>This type serves the purpose of being able to safely generate a C-compatible string from a Rust byte slice or vector. An instance of this type is a static guarantee that the underlying bytes contain no interior 0 bytes ("nul characters") and that the final byte is 0 ("nul terminator").</p> <p><code>CString</code> is to <a href="struct.CStr.html"><code>&CStr</code></a> as <a href="../string/struct.String.html"><code>String</code></a> is to <a href="../primitive.str.html"><code>&str</code></a>: the former in each pair are owned strings; the latter are borrowed references.</p> <h1 id="creating-a-cstring" class="section-header"><a href="#creating-a-cstring">Creating a <code>CString</code></a></h1> <p>A <code>CString</code> is created from either a byte slice or a byte vector, or anything that implements <a href="../convert/trait.Into.html"><code>Into</code></a><code><</code><a href="../vec/struct.Vec.html"><code>Vec</code></a><code><</code><a href="../primitive.u8.html"><code>u8</code></a><code>>></code> (for example, you can build a <code>CString</code> straight out of a <a href="../string/struct.String.html"><code>String</code></a> or a <a href="../primitive.str.html"><code>&str</code></a>, since both implement that trait).</p> <p>The <a href="#method.new"><code>new</code></a> method will actually check that the provided <code>&[u8]</code> does not have 0 bytes in the middle, and return an error if it finds one.</p> <h1 id="extracting-a-raw-pointer-to-the-whole-c-string" class="section-header"><a href="#extracting-a-raw-pointer-to-the-whole-c-string">Extracting a raw pointer to the whole C string</a></h1> <p><code>CString</code> implements a <a href="#method.as_ptr"><code>as_ptr</code></a> method through the <a href="../ops/trait.Deref.html"><code>Deref</code></a> trait. This method will give you a <code>*const c_char</code> which you can feed directly to extern functions that expect a nul-terminated string, like C's <code>strdup()</code>.</p> <h1 id="extracting-a-slice-of-the-whole-c-string" class="section-header"><a href="#extracting-a-slice-of-the-whole-c-string">Extracting a slice of the whole C string</a></h1> <p>Alternatively, you can obtain a <code>&[</code><a href="../primitive.u8.html"><code>u8</code></a><code>]</code> slice from a <code>CString</code> with the <a href="#method.as_bytes"><code>as_bytes</code></a> method. Slices produced in this way do <em>not</em> contain the trailing nul terminator. This is useful when you will be calling an extern function that takes a <code>*const u8</code> argument which is not necessarily nul-terminated, plus another argument with the length of the string — like C's <code>strndup()</code>. You can of course get the slice's length with its <a href="../primitive.slice.html#method.len"><code>len</code></a> method.</p> <p>If you need a <code>&[</code><a href="../primitive.u8.html"><code>u8</code></a><code>]</code> slice <em>with</em> the nul terminator, you can use <a href="#method.as_bytes_with_nul"><code>as_bytes_with_nul</code></a> instead.</p> <p>Once you have the kind of slice you need (with or without a nul terminator), you can call the slice's own <a href="../primitive.slice.html#method.as_ptr"><code>as_ptr</code></a> method to get a raw pointer to pass to extern functions. See the documentation for that function for a discussion on ensuring the lifetime of the raw pointer.</p> <h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1> <div class='information'><div class='tooltip ignore'>ⓘ<span class='tooltiptext'>This example is not tested</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">raw</span>::<span class="ident">c_char</span>; <span class="kw">extern</span> { <span class="kw">fn</span> <span class="ident">my_printer</span>(<span class="ident">s</span>: <span class="kw-2">*</span><span class="kw">const</span> <span class="ident">c_char</span>); } <span class="comment">// We are certain that our string doesn't have 0 bytes in the middle,</span> <span class="comment">// so we can .expect()</span> <span class="kw">let</span> <span class="ident">c_to_print</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"Hello, world!"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">unsafe</span> { <span class="ident">my_printer</span>(<span class="ident">c_to_print</span>.<span class="ident">as_ptr</span>()); }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0Ause%20std%3A%3Aos%3A%3Araw%3A%3Ac_char%3B%0A%0Aextern%20%7B%0A%20%20%20%20fn%20my_printer(s%3A%20*const%20c_char)%3B%0A%7D%0A%0A%2F%2F%20We%20are%20certain%20that%20our%20string%20doesn't%20have%200%20bytes%20in%20the%20middle%2C%0A%2F%2F%20so%20we%20can%20.expect()%0Alet%20c_to_print%20%3D%20CString%3A%3Anew(%22Hello%2C%20world!%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Aunsafe%20%7B%0A%20%20%20%20my_printer(c_to_print.as_ptr())%3B%0A%7D%0A%7D">Run</a></pre></div> <h1 id="safety" class="section-header"><a href="#safety">Safety</a></h1> <p><code>CString</code> is intended for working with traditional C-style strings (a sequence of non-nul bytes terminated by a single nul byte); the primary use case for these kinds of strings is interoperating with C-like code. Often you will need to transfer ownership to/from that external code. It is strongly recommended that you thoroughly read through the documentation of <code>CString</code> before use, as improper ownership management of <code>CString</code> instances can lead to invalid memory accesses, memory leaks, and other memory errors.</p> </div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#290-606' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a><T: <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a><<a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>>>>(t: T) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>, <a class="struct" href="../../std/ffi/struct.NulError.html" title="struct std::ffi::NulError">NulError</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#321-323' title='goto source code'>[src]</a></h4><div class='docblock'><p>Creates a new C-compatible string from a container of bytes.</p> <p>This function will consume the provided data and use the underlying bytes to construct a new string, ensuring that there is a trailing 0 byte. This trailing 0 byte will be appended by this function; the provided data should <em>not</em> contain any 0 bytes in it.</p> <h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1> <div class='information'><div class='tooltip ignore'>ⓘ<span class='tooltiptext'>This example is not tested</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">raw</span>::<span class="ident">c_char</span>; <span class="kw">extern</span> { <span class="kw">fn</span> <span class="ident">puts</span>(<span class="ident">s</span>: <span class="kw-2">*</span><span class="kw">const</span> <span class="ident">c_char</span>); } <span class="kw">let</span> <span class="ident">to_print</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"Hello!"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">unsafe</span> { <span class="ident">puts</span>(<span class="ident">to_print</span>.<span class="ident">as_ptr</span>()); }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0Ause%20std%3A%3Aos%3A%3Araw%3A%3Ac_char%3B%0A%0Aextern%20%7B%20fn%20puts(s%3A%20*const%20c_char)%3B%20%7D%0A%0Alet%20to_print%20%3D%20CString%3A%3Anew(%22Hello!%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Aunsafe%20%7B%0A%20%20%20%20puts(to_print.as_ptr())%3B%0A%7D%0A%7D">Run</a></pre></div> <h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1> <p>This function will return an error if the supplied bytes contain an internal 0 byte. The <a href="struct.NulError.html"><code>NulError</code></a> returned will contain the bytes as well as the position of the nul byte.</p> </div><h4 id='method.from_vec_unchecked' class="method"><code id='from_vec_unchecked.v'>pub unsafe fn <a href='#method.from_vec_unchecked' class='fnname'>from_vec_unchecked</a>(v: <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>>) -> <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#352-356' title='goto source code'>[src]</a></h4><div class='docblock'><p>Creates a C-compatible string by consuming a byte vector, without checking for interior 0 bytes.</p> <p>This method is equivalent to <a href="#method.new"><code>new</code></a> except that no runtime assertion is made that <code>v</code> contains no 0 bytes, and it requires an actual byte vector, not anything that can be converted to one with Into.</p> <h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">raw</span> <span class="op">=</span> <span class="string">b"foo"</span>.<span class="ident">to_vec</span>(); <span class="kw">unsafe</span> { <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">from_vec_unchecked</span>(<span class="ident">raw</span>); }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20raw%20%3D%20b%22foo%22.to_vec()%3B%0Aunsafe%20%7B%0A%20%20%20%20let%20c_string%20%3D%20CString%3A%3Afrom_vec_unchecked(raw)%3B%0A%7D%0A%7D">Run</a></pre></div> </div><h4 id='method.from_raw' class="method"><code id='from_raw.v'>pub unsafe fn <a href='#method.from_raw' class='fnname'>from_raw</a>(ptr: <a class="primitive" href="../primitive.pointer.html">*mut </a><a class="type" href="../../std/os/raw/type.c_char.html" title="type std::os::raw::c_char">c_char</a>) -> <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#399-403' title='goto source code'>[src]</a></h4><div class='docblock'><p>Retakes ownership of a <code>CString</code> that was transferred to C via <a href="#method.into_raw"><code>into_raw</code></a>.</p> <p>Additionally, the length of the string will be recalculated from the pointer.</p> <h1 id="safety-1" class="section-header"><a href="#safety-1">Safety</a></h1> <p>This should only ever be called with a pointer that was earlier obtained by calling <a href="#method.into_raw"><code>into_raw</code></a> on a <code>CString</code>. Other usage (e.g., trying to take ownership of a string that was allocated by foreign code) is likely to lead to undefined behavior or allocator corruption.</p> <blockquote> <p><strong>Note:</strong> If you need to borrow a string that was allocated by foreign code, use <a href="struct.CStr.html"><code>CStr</code></a>. If you need to take ownership of a string that was allocated by foreign code, you will need to make your own provisions for freeing it appropriately, likely with the foreign code's API to do that.</p> </blockquote> <h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1> <p>Creates a <code>CString</code>, pass ownership to an <code>extern</code> function (via raw pointer), then retake ownership with <code>from_raw</code>:</p> <div class='information'><div class='tooltip ignore'>ⓘ<span class='tooltiptext'>This example is not tested</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">raw</span>::<span class="ident">c_char</span>; <span class="kw">extern</span> { <span class="kw">fn</span> <span class="ident">some_extern_function</span>(<span class="ident">s</span>: <span class="kw-2">*</span><span class="kw-2">mut</span> <span class="ident">c_char</span>); } <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"Hello!"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">raw</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">into_raw</span>(); <span class="kw">unsafe</span> { <span class="ident">some_extern_function</span>(<span class="ident">raw</span>); <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">from_raw</span>(<span class="ident">raw</span>); }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0Ause%20std%3A%3Aos%3A%3Araw%3A%3Ac_char%3B%0A%0Aextern%20%7B%0A%20%20%20%20fn%20some_extern_function(s%3A%20*mut%20c_char)%3B%0A%7D%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(%22Hello!%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20raw%20%3D%20c_string.into_raw()%3B%0Aunsafe%20%7B%0A%20%20%20%20some_extern_function(raw)%3B%0A%20%20%20%20let%20c_string%20%3D%20CString%3A%3Afrom_raw(raw)%3B%0A%7D%0A%7D">Run</a></pre></div> </div><h4 id='method.into_raw' class="method"><code id='into_raw.v'>pub fn <a href='#method.into_raw' class='fnname'>into_raw</a>(self) -> <a class="primitive" href="../primitive.pointer.html">*mut </a><a class="type" href="../../std/os/raw/type.c_char.html" title="type std::os::raw::c_char">c_char</a></code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#437-439' title='goto source code'>[src]</a></h4><div class='docblock'><p>Consumes the <code>CString</code> and transfers ownership of the string to a C caller.</p> <p>The pointer which this function returns must be returned to Rust and reconstituted using <a href="#method.from_raw"><code>from_raw</code></a> to be properly deallocated. Specifically, one should <em>not</em> use the standard C <code>free()</code> function to deallocate this string.</p> <p>Failure to call <a href="#method.from_raw"><code>from_raw</code></a> will lead to a memory leak.</p> <h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"foo"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">ptr</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">into_raw</span>(); <span class="kw">unsafe</span> { <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">b'f'</span>, <span class="kw-2">*</span><span class="ident">ptr</span> <span class="kw">as</span> <span class="ident">u8</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">b'o'</span>, <span class="kw-2">*</span><span class="ident">ptr</span>.<span class="ident">offset</span>(<span class="number">1</span>) <span class="kw">as</span> <span class="ident">u8</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">b'o'</span>, <span class="kw-2">*</span><span class="ident">ptr</span>.<span class="ident">offset</span>(<span class="number">2</span>) <span class="kw">as</span> <span class="ident">u8</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">b'\0'</span>, <span class="kw-2">*</span><span class="ident">ptr</span>.<span class="ident">offset</span>(<span class="number">3</span>) <span class="kw">as</span> <span class="ident">u8</span>); <span class="comment">// retake pointer to free memory</span> <span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">from_raw</span>(<span class="ident">ptr</span>); }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(%22foo%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0A%0Alet%20ptr%20%3D%20c_string.into_raw()%3B%0A%0Aunsafe%20%7B%0A%20%20%20%20assert_eq!(b'f'%2C%20*ptr%20as%20u8)%3B%0A%20%20%20%20assert_eq!(b'o'%2C%20*ptr.offset(1)%20as%20u8)%3B%0A%20%20%20%20assert_eq!(b'o'%2C%20*ptr.offset(2)%20as%20u8)%3B%0A%20%20%20%20assert_eq!(b'%5C0'%2C%20*ptr.offset(3)%20as%20u8)%3B%0A%0A%20%20%20%20%2F%2F%20retake%20pointer%20to%20free%20memory%0A%20%20%20%20let%20_%20%3D%20CString%3A%3Afrom_raw(ptr)%3B%0A%7D%0A%7D">Run</a></pre></div> </div><h4 id='method.into_string' class="method"><code id='into_string.v'>pub fn <a href='#method.into_string' class='fnname'>into_string</a>(self) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><<a class="struct" href="../../std/string/struct.String.html" title="struct std::string::String">String</a>, <a class="struct" href="../../std/ffi/struct.IntoStringError.html" title="struct std::ffi::IntoStringError">IntoStringError</a>></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#463-469' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts the <code>CString</code> into a <a href="../string/struct.String.html"><code>String</code></a> if it contains valid UTF-8 data.</p> <p>On failure, ownership of the original <code>CString</code> is returned.</p> <h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">valid_utf8</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">b'f'</span>, <span class="string">b'o'</span>, <span class="string">b'o'</span>]; <span class="kw">let</span> <span class="ident">cstring</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="ident">valid_utf8</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cstring</span>.<span class="ident">into_string</span>().<span class="ident">expect</span>(<span class="string">"into_string() call failed"</span>), <span class="string">"foo"</span>); <span class="kw">let</span> <span class="ident">invalid_utf8</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">b'f'</span>, <span class="number">0xff</span>, <span class="string">b'o'</span>, <span class="string">b'o'</span>]; <span class="kw">let</span> <span class="ident">cstring</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="ident">invalid_utf8</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">err</span> <span class="op">=</span> <span class="ident">cstring</span>.<span class="ident">into_string</span>().<span class="ident">err</span>().<span class="ident">expect</span>(<span class="string">"into_string().err() failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">err</span>.<span class="ident">utf8_error</span>().<span class="ident">valid_up_to</span>(), <span class="number">1</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20valid_utf8%20%3D%20vec!%5Bb'f'%2C%20b'o'%2C%20b'o'%5D%3B%0Alet%20cstring%20%3D%20CString%3A%3Anew(valid_utf8).expect(%22CString%3A%3Anew%20failed%22)%3B%0Aassert_eq!(cstring.into_string().expect(%22into_string()%20call%20failed%22)%2C%20%22foo%22)%3B%0A%0Alet%20invalid_utf8%20%3D%20vec!%5Bb'f'%2C%200xff%2C%20b'o'%2C%20b'o'%5D%3B%0Alet%20cstring%20%3D%20CString%3A%3Anew(invalid_utf8).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20err%20%3D%20cstring.into_string().err().expect(%22into_string().err()%20failed%22)%3B%0Aassert_eq!(err.utf8_error().valid_up_to()%2C%201)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.into_bytes' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></span></code></div></div><code id='into_bytes.v'>pub fn <a href='#method.into_bytes' class='fnname'>into_bytes</a>(self) -> <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#487-492' title='goto source code'>[src]</a></h4><div class='docblock'><p>Consumes the <code>CString</code> and returns the underlying byte buffer.</p> <p>The returned buffer does <strong>not</strong> contain the trailing nul terminator, and it is guaranteed to not have any interior nul bytes.</p> <h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"foo"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">into_bytes</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">bytes</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="string">b'f'</span>, <span class="string">b'o'</span>, <span class="string">b'o'</span>]);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(%22foo%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20bytes%20%3D%20c_string.into_bytes()%3B%0Aassert_eq!(bytes%2C%20vec!%5Bb'f'%2C%20b'o'%2C%20b'o'%5D)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.into_bytes_with_nul' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></span></code></div></div><code id='into_bytes_with_nul.v'>pub fn <a href='#method.into_bytes_with_nul' class='fnname'>into_bytes_with_nul</a>(self) -> <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#509-511' title='goto source code'>[src]</a></h4><div class='docblock'><p>Equivalent to the <a href="#method.into_bytes"><code>into_bytes</code></a> function except that the returned vector includes the trailing nul terminator.</p> <h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"foo"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">into_bytes_with_nul</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">bytes</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="string">b'f'</span>, <span class="string">b'o'</span>, <span class="string">b'o'</span>, <span class="string">b'\0'</span>]);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(%22foo%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20bytes%20%3D%20c_string.into_bytes_with_nul()%3B%0Aassert_eq!(bytes%2C%20vec!%5Bb'f'%2C%20b'o'%2C%20b'o'%2C%20b'%5C0'%5D)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.as_bytes' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></h3><code class="content"><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.slice.html">&'_ mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></code></div></div><code id='as_bytes.v'>pub fn <a href='#method.as_bytes' class='fnname'>as_bytes</a>(&self) -> <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#533-535' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the contents of this <code>CString</code> as a slice of bytes.</p> <p>The returned slice does <strong>not</strong> contain the trailing nul terminator, and it is guaranteed to not have any interior nul bytes. If you need the nul terminator, use <a href="#method.as_bytes_with_nul"><code>as_bytes_with_nul</code></a> instead.</p> <h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"foo"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">as_bytes</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">bytes</span>, <span class="kw-2">&</span>[<span class="string">b'f'</span>, <span class="string">b'o'</span>, <span class="string">b'o'</span>]);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(%22foo%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20bytes%20%3D%20c_string.as_bytes()%3B%0Aassert_eq!(bytes%2C%20%26%5Bb'f'%2C%20b'o'%2C%20b'o'%5D)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.as_bytes_with_nul' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></h3><code class="content"><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.slice.html">&'_ mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></code></div></div><code id='as_bytes_with_nul.v'>pub fn <a href='#method.as_bytes_with_nul' class='fnname'>as_bytes_with_nul</a>(&self) -> <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#553-555' title='goto source code'>[src]</a></h4><div class='docblock'><p>Equivalent to the <a href="#method.as_bytes"><code>as_bytes</code></a> function except that the returned slice includes the trailing nul terminator.</p> <h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CString</span>; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"foo"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">as_bytes_with_nul</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">bytes</span>, <span class="kw-2">&</span>[<span class="string">b'f'</span>, <span class="string">b'o'</span>, <span class="string">b'o'</span>, <span class="string">b'\0'</span>]);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACString%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(%22foo%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20bytes%20%3D%20c_string.as_bytes_with_nul()%3B%0Aassert_eq!(bytes%2C%20%26%5Bb'f'%2C%20b'o'%2C%20b'o'%2C%20b'%5C0'%5D)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.as_c_str' class="method"><code id='as_c_str.v'>pub fn <a href='#method.as_c_str' class='fnname'>as_c_str</a>(&self) -> &<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code><div class='since' title='Stable since Rust version 1.20.0'>1.20.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#573-575' title='goto source code'>[src]</a></h4><div class='docblock'><p>Extracts a <a href="struct.CStr.html"><code>CStr</code></a> slice containing the entire string.</p> <h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::{<span class="ident">CString</span>, <span class="ident">CStr</span>}; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">b"foo"</span>.<span class="ident">to_vec</span>()).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">c_str</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">as_c_str</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">c_str</span>, <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"foo\0"</span>).<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3A%7BCString%2C%20CStr%7D%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(b%22foo%22.to_vec()).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20c_str%20%3D%20c_string.as_c_str()%3B%0Aassert_eq!(c_str%2C%0A%20%20%20%20%20%20%20%20%20%20%20CStr%3A%3Afrom_bytes_with_nul(b%22foo%5C0%22).expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22))%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.into_boxed_c_str' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><I></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><I></h3><code class="content"><span class="where fmt-newline">impl<I> <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><I> <span class="where fmt-newline">where<br> I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>>::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<F> <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><F> <span class="where fmt-newline">where<br> F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>>::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl<R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><R></span><span class="where fmt-newline">impl<W: <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><W></span></code></div></div><code id='into_boxed_c_str.v'>pub fn <a href='#method.into_boxed_c_str' class='fnname'>into_boxed_c_str</a>(self) -> <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><div class='since' title='Stable since Rust version 1.20.0'>1.20.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#592-594' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts this <code>CString</code> into a boxed <a href="struct.CStr.html"><code>CStr</code></a>.</p> <h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::{<span class="ident">CString</span>, <span class="ident">CStr</span>}; <span class="kw">let</span> <span class="ident">c_string</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">b"foo"</span>.<span class="ident">to_vec</span>()).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">boxed</span> <span class="op">=</span> <span class="ident">c_string</span>.<span class="ident">into_boxed_c_str</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="kw-2">*</span><span class="ident">boxed</span>, <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"foo\0"</span>).<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3A%7BCString%2C%20CStr%7D%3B%0A%0Alet%20c_string%20%3D%20CString%3A%3Anew(b%22foo%22.to_vec()).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20boxed%20%3D%20c_string.into_boxed_c_str()%3B%0Aassert_eq!(%26*boxed%2C%0A%20%20%20%20%20%20%20%20%20%20%20CStr%3A%3Afrom_bytes_with_nul(b%22foo%5C0%22).expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22))%3B%0A%7D">Run</a></pre></div> </div></div><h2 id='deref-methods' class='small-section-header'>Methods from <a class="trait" href="../../std/ops/trait.Deref.html" title="trait std::ops::Deref">Deref</a><Target = <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>><a href='#deref-methods' class='anchor'></a></h2><div class='impl-items'><h4 id='method.as_ptr' class="method"><code id='as_ptr.v'>pub const fn <a href='#method.as_ptr' class='fnname'>as_ptr</a>(&self) -> <a class="primitive" href="../primitive.pointer.html">*const </a><a class="type" href="../../std/os/raw/type.c_char.html" title="type std::os::raw::c_char">c_char</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1084-1086' title='goto source code'>[src]</a></h4><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><strong>WARNING</strong></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"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::{<span class="ident">CString</span>}; <span class="kw">let</span> <span class="ident">ptr</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"Hello"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>).<span class="ident">as_ptr</span>(); <span class="kw">unsafe</span> { <span class="comment">// `ptr` is dangling</span> <span class="kw-2">*</span><span class="ident">ptr</span>; }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Ballow(unused_must_use)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3A%7BCString%7D%3B%0A%0Alet%20ptr%20%3D%20CString%3A%3Anew(%22Hello%22).expect(%22CString%3A%3Anew%20failed%22).as_ptr()%3B%0Aunsafe%20%7B%0A%20%20%20%20%2F%2F%20%60ptr%60%20is%20dangling%0A%20%20%20%20*ptr%3B%0A%7D%0A%7D">Run</a></pre></div> <p>This happens because the pointer returned by <code>as_ptr</code> does not carry any lifetime information and the <a href="struct.CString.html"><code>CString</code></a> is deallocated immediately after the <code>CString::new("Hello").expect("CString::new failed").as_ptr()</code> expression is 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"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::{<span class="ident">CString</span>}; <span class="kw">let</span> <span class="ident">hello</span> <span class="op">=</span> <span class="ident">CString</span>::<span class="ident">new</span>(<span class="string">"Hello"</span>).<span class="ident">expect</span>(<span class="string">"CString::new failed"</span>); <span class="kw">let</span> <span class="ident">ptr</span> <span class="op">=</span> <span class="ident">hello</span>.<span class="ident">as_ptr</span>(); <span class="kw">unsafe</span> { <span class="comment">// `ptr` is valid because `hello` is in scope</span> <span class="kw-2">*</span><span class="ident">ptr</span>; }<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Ballow(unused_must_use)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3A%7BCString%7D%3B%0A%0Alet%20hello%20%3D%20CString%3A%3Anew(%22Hello%22).expect(%22CString%3A%3Anew%20failed%22)%3B%0Alet%20ptr%20%3D%20hello.as_ptr()%3B%0Aunsafe%20%7B%0A%20%20%20%20%2F%2F%20%60ptr%60%20is%20valid%20because%20%60hello%60%20is%20in%20scope%0A%20%20%20%20*ptr%3B%0A%7D%0A%7D">Run</a></pre></div> <p>This way, the lifetime of the <code>CString</code> in <code>hello</code> encompasses the lifetime of <code>ptr</code> and the <code>unsafe</code> block.</p> </div><h4 id='method.to_bytes' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></h3><code class="content"><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.slice.html">&'_ mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></code></div></div><code id='to_bytes.v'>pub fn <a href='#method.to_bytes' class='fnname'>to_bytes</a>(&self) -> <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1107-1110' title='goto source code'>[src]</a></h4><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> <h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CStr</span>; <span class="kw">let</span> <span class="ident">c_str</span> <span class="op">=</span> <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"foo\0"</span>).<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">c_str</span>.<span class="ident">to_bytes</span>(), <span class="string">b"foo"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACStr%3B%0A%0Alet%20c_str%20%3D%20CStr%3A%3Afrom_bytes_with_nul(b%22foo%5C0%22).expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22)%3B%0Aassert_eq!(c_str.to_bytes()%2C%20b%22foo%22)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.to_bytes_with_nul' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></h3><code class="content"><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.slice.html">&'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span><span class="where fmt-newline">impl<'_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.slice.html">&'_ mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></code></div></div><code id='to_bytes_with_nul.v'>pub fn <a href='#method.to_bytes_with_nul' class='fnname'>to_bytes_with_nul</a>(&self) -> <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1133-1135' title='goto source code'>[src]</a></h4><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="#method.to_bytes"><code>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> <h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CStr</span>; <span class="kw">let</span> <span class="ident">c_str</span> <span class="op">=</span> <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"foo\0"</span>).<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">c_str</span>.<span class="ident">to_bytes_with_nul</span>(), <span class="string">b"foo\0"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACStr%3B%0A%0Alet%20c_str%20%3D%20CStr%3A%3Afrom_bytes_with_nul(b%22foo%5C0%22).expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22)%3B%0Aassert_eq!(c_str.to_bytes_with_nul()%2C%20b%22foo%5C0%22)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.to_str' class="method"><code id='to_str.v'>pub fn <a href='#method.to_str' class='fnname'>to_str</a>(&self) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><&<a class="primitive" href="../primitive.str.html">str</a>, <a class="struct" href="../../std/str/struct.Utf8Error.html" title="struct std::str::Utf8Error">Utf8Error</a>></code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1159-1165' title='goto source code'>[src]</a></h4><div class='docblock'><p>Yields a <a href="../primitive.str.html"><code>&str</code></a> 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 <a href="../primitive.str.html"><code>&str</code></a> slice. Otherwise, it will return an error with details of where UTF-8 validation failed.</p> <blockquote> <p><strong>Note</strong>: This method is currently implemented to check for validity after a constant-time cast, but it is planned to alter its definition in the future to perform the length calculation in addition to the UTF-8 check whenever this method is called.</p> </blockquote> <h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CStr</span>; <span class="kw">let</span> <span class="ident">c_str</span> <span class="op">=</span> <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"foo\0"</span>).<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">c_str</span>.<span class="ident">to_str</span>(), <span class="prelude-val">Ok</span>(<span class="string">"foo"</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Affi%3A%3ACStr%3B%0A%0Alet%20c_str%20%3D%20CStr%3A%3Afrom_bytes_with_nul(b%22foo%5C0%22).expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22)%3B%0Aassert_eq!(c_str.to_str()%2C%20Ok(%22foo%22))%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.to_string_lossy' class="method"><code id='to_string_lossy.v'>pub fn <a href='#method.to_string_lossy' class='fnname'>to_string_lossy</a>(&self) -> <a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><<a class="primitive" href="../primitive.str.html">str</a>></code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1215-1217' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts a <code>CStr</code> into a <a href="../borrow/enum.Cow.html"><code>Cow</code></a><code><</code><a href="../primitive.str.html"><code>str</code></a><code>></code>.</p> <p>If the contents of the <code>CStr</code> are valid UTF-8 data, this function will return a <a href="../borrow/enum.Cow.html"><code>Cow</code></a><code>::</code><a href="../borrow/enum.Cow.html#variant.Borrowed"><code>Borrowed</code></a><code>(</code>[<code>&str</code>]<code>)</code> with the corresponding [<code>&str</code>] slice. Otherwise, it will replace any invalid UTF-8 sequences with <a href="../char/constant.REPLACEMENT_CHARACTER.html"><code>U+FFFD REPLACEMENT CHARACTER</code></a> and return a <a href="../borrow/enum.Cow.html"><code>Cow</code></a><code>::</code><a href="../borrow/enum.Cow.html#variant.Owned"><code>Owned</code></a><code>(</code><a href="../string/struct.String.html"><code>String</code></a><code>)</code> with the result.</p> <blockquote> <p><strong>Note</strong>: This method is currently implemented to check for validity after a constant-time cast, but it is planned to alter its definition in the future to perform the length calculation in addition to the UTF-8 check whenever this method is called.</p> </blockquote> <h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1> <p>Calling <code>to_string_lossy</code> on a <code>CStr</code> containing valid UTF-8:</p> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Cow</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CStr</span>; <span class="kw">let</span> <span class="ident">c_str</span> <span class="op">=</span> <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"Hello World\0"</span>) .<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">c_str</span>.<span class="ident">to_string_lossy</span>(), <span class="ident">Cow</span>::<span class="ident">Borrowed</span>(<span class="string">"Hello World"</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Aborrow%3A%3ACow%3B%0Ause%20std%3A%3Affi%3A%3ACStr%3B%0A%0Alet%20c_str%20%3D%20CStr%3A%3Afrom_bytes_with_nul(b%22Hello%20World%5C0%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22)%3B%0Aassert_eq!(c_str.to_string_lossy()%2C%20Cow%3A%3ABorrowed(%22Hello%20World%22))%3B%0A%7D">Run</a></pre></div> <p>Calling <code>to_string_lossy</code> on a <code>CStr</code> containing invalid UTF-8:</p> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Cow</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">CStr</span>; <span class="kw">let</span> <span class="ident">c_str</span> <span class="op">=</span> <span class="ident">CStr</span>::<span class="ident">from_bytes_with_nul</span>(<span class="string">b"Hello \xF0\x90\x80World\0"</span>) .<span class="ident">expect</span>(<span class="string">"CStr::from_bytes_with_nul failed"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>( <span class="ident">c_str</span>.<span class="ident">to_string_lossy</span>(), <span class="ident">Cow</span>::<span class="ident">Owned</span>(<span class="ident">String</span>::<span class="ident">from</span>(<span class="string">"Hello �World"</span>)) <span class="kw">as</span> <span class="ident">Cow</span><span class="op"><</span><span class="lifetime">'_</span>, <span class="ident">str</span><span class="op">></span> );<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Aborrow%3A%3ACow%3B%0Ause%20std%3A%3Affi%3A%3ACStr%3B%0A%0Alet%20c_str%20%3D%20CStr%3A%3Afrom_bytes_with_nul(b%22Hello%20%5CxF0%5Cx90%5Cx80World%5C0%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.expect(%22CStr%3A%3Afrom_bytes_with_nul%20failed%22)%3B%0Aassert_eq!(%0A%20%20%20%20c_str.to_string_lossy()%2C%0A%20%20%20%20Cow%3A%3AOwned(String%3A%3Afrom(%22Hello%20%EF%BF%BDWorld%22))%20as%20Cow%3C'_%2C%20str%3E%0A)%3B%0A%7D">Run</a></pre></div> </div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Deref' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/ops/trait.Deref.html" title="trait std::ops::Deref">Deref</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Deref' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#620-627' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Target' class="type"><code id='Target.t'>type <a href='../../std/ops/trait.Deref.html#associatedtype.Target' class="type">Target</a> = <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code></h4><div class='docblock'><p>The resulting type after dereferencing.</p> </div><h4 id='method.deref' class="method hidden"><code id='deref.v'>fn <a href='../../std/ops/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&self) -> &<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#624-626' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Dereferences the value.</p> </div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#630-634' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='../../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="../../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -> <a class="type" href="../../std/fmt/type.Result.html" title="type std::fmt::Result">Result</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#631-633' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="../../std/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p> </div></div><h3 id='impl-PartialEq%3CCString%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/cmp/trait.PartialEq.html" title="trait std::cmp::PartialEq">PartialEq</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-PartialEq%3CCString%3E' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.eq' class="method hidden"><code id='eq.v'>fn <a href='../../std/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="../../std/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p> </div><h4 id='method.ne' class="method hidden"><code id='ne.v'>fn <a href='../../std/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p> </div></div><h3 id='impl-Eq' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/cmp/trait.Eq.html" title="trait std::cmp::Eq">Eq</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Eq' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h3><div class='impl-items'></div><h3 id='impl-Ord' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/cmp/trait.Ord.html" title="trait std::cmp::Ord">Ord</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Ord' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.cmp' class="method hidden"><code id='cmp.v'>fn <a href='../../std/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="enum" href="../../std/cmp/enum.Ordering.html" title="enum std::cmp::Ordering">Ordering</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method returns an <code>Ordering</code> between <code>self</code> and <code>other</code>. <a href="../../std/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p> </div><h4 id='method.max' class="method"><code id='max.v'>fn <a href='../../std/cmp/trait.Ord.html#method.max' class='fnname'>max</a>(self, other: Self) -> Self</code><div class='since' title='Stable since Rust version 1.21.0'>1.21.0</div><a class='srclink' href='../../src/core/cmp.rs.html#549-552' title='goto source code'>[src]</a></h4><div class='docblock'><p>Compares and returns the maximum of two values. <a href="../../std/cmp/trait.Ord.html#method.max">Read more</a></p> </div><h4 id='method.min' class="method"><code id='min.v'>fn <a href='../../std/cmp/trait.Ord.html#method.min' class='fnname'>min</a>(self, other: Self) -> Self</code><div class='since' title='Stable since Rust version 1.21.0'>1.21.0</div><a class='srclink' href='../../src/core/cmp.rs.html#566-569' title='goto source code'>[src]</a></h4><div class='docblock'><p>Compares and returns the minimum of two values. <a href="../../std/cmp/trait.Ord.html#method.min">Read more</a></p> </div><h4 id='method.clamp' class="method"><code id='clamp.v'>fn <a href='../../std/cmp/trait.Ord.html#method.clamp' class='fnname'>clamp</a>(self, min: Self, max: Self) -> Self</code><a class='srclink' href='../../src/core/cmp.rs.html#590-600' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>clamp</code> <a href="https://github.com/rust-lang/rust/issues/44095">#44095</a>)</div></div><div class='docblock'><p>Restrict a value to a certain interval. <a href="../../std/cmp/trait.Ord.html#method.clamp">Read more</a></p> </div></div><h3 id='impl-PartialOrd%3CCString%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/cmp/trait.PartialOrd.html" title="trait std::cmp::PartialOrd">PartialOrd</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-PartialOrd%3CCString%3E' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.partial_cmp' class="method hidden"><code id='partial_cmp.v'>fn <a href='../../std/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a><<a class="enum" href="../../std/cmp/enum.Ordering.html" title="enum std::cmp::Ordering">Ordering</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="../../std/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p> </div><h4 id='method.lt' class="method hidden"><code id='lt.v'>fn <a href='../../std/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a href="../../std/cmp/trait.PartialOrd.html#method.lt">Read more</a></p> </div><h4 id='method.le' class="method hidden"><code id='le.v'>fn <a href='../../std/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> operator. <a href="../../std/cmp/trait.PartialOrd.html#method.le">Read more</a></p> </div><h4 id='method.gt' class="method hidden"><code id='gt.v'>fn <a href='../../std/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a href="../../std/cmp/trait.PartialOrd.html#method.gt">Read more</a></p> </div><h4 id='method.ge' class="method hidden"><code id='ge.v'>fn <a href='../../std/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&self, other: &<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> operator. <a href="../../std/cmp/trait.PartialOrd.html#method.ge">Read more</a></p> </div></div><h3 id='impl-From%3CCString%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></code><a href='#impl-From%3CCString%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#637-648' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></span></code></div></div><code id='from.v'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#645-647' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts a <a href="../ffi/struct.CString.html"><code>CString</code></a> into a <a href="../vec/struct.Vec.html"><code>Vec</code></a><code><u8></code>.</p> <p>The conversion consumes the <a href="../ffi/struct.CString.html"><code>CString</code></a>, and removes the terminating NUL byte.</p> </div></div><h3 id='impl-From%3CCow%3C%27a%2C%20CStr%3E%3E' class='impl'><code class='in-band'>impl<'a> <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><'a, <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-From%3CCow%3C%27a%2C%20CStr%3E%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.28.0'>1.28.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#685-690' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-1' class="method hidden"><code id='from.v-1'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><'a, <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>>) -> Self</code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#687-689' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-From%3CBox%3CCStr%3E%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-From%3CBox%3CCStr%3E%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.18.0'>1.18.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#701-710' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-2' class="method"><code id='from.v-2'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>>) -> <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#707-709' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts a <a href="../boxed/struct.Box.html"><code>Box</code></a><code><CStr></code> into a <a href="../ffi/struct.CString.html"><code>CString</code></a> without copying or allocating.</p> </div></div><h3 id='impl-From%3CCString%3E-1' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a href='#impl-From%3CCString%3E-1' class='anchor'></a><div class='since' title='Stable since Rust version 1.20.0'>1.20.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#721-730' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-3' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><I></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><I></h3><code class="content"><span class="where fmt-newline">impl<I> <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><I> <span class="where fmt-newline">where<br> I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>>::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<F> <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><F> <span class="where fmt-newline">where<br> F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>>::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl<R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><R></span><span class="where fmt-newline">impl<W: <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><W></span></code></div></div><code id='from.v-3'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="struct" href="../../std/boxed/struct.Box.html" title="struct std::boxed::Box">Box</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#727-729' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts a <a href="../ffi/struct.CString.html"><code>CString</code></a> into a <a href="../boxed/struct.Box.html"><code>Box</code></a><code><CStr></code> without copying or allocating.</p> </div></div><h3 id='impl-From%3CCString%3E-2' class='impl'><code class='in-band'>impl<'a> <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><'a, <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a href='#impl-From%3CCString%3E-2' class='anchor'></a><div class='since' title='Stable since Rust version 1.28.0'>1.28.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#733-738' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-4' class="method hidden"><code id='from.v-4'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><'a, <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#735-737' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-From%3C%26%27a%20CString%3E' class='impl'><code class='in-band'>impl<'a> <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><&'a <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><'a, <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a href='#impl-From%3C%26%27a%20CString%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.28.0'>1.28.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#749-754' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-5' class="method hidden"><code id='from.v-5'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: &'a <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="enum" href="../../std/borrow/enum.Cow.html" title="enum std::borrow::Cow">Cow</a><'a, <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#751-753' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-From%3CCString%3E-3' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="struct" href="../../std/sync/struct.Arc.html" title="struct std::sync::Arc">Arc</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a href='#impl-From%3CCString%3E-3' class='anchor'></a><div class='since' title='Stable since Rust version 1.24.0'>1.24.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#757-767' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-6' class="method"><code id='from.v-6'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="struct" href="../../std/sync/struct.Arc.html" title="struct std::sync::Arc">Arc</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#763-766' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts a <a href="../ffi/struct.CString.html"><code>CString</code></a> into a <a href="../sync/struct.Arc.html"><code>Arc</code></a><code><CStr></code> without copying or allocating.</p> </div></div><h3 id='impl-From%3CCString%3E-4' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>> for <a class="struct" href="../../std/rc/struct.Rc.html" title="struct std::rc::Rc">Rc</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a href='#impl-From%3CCString%3E-4' class='anchor'></a><div class='since' title='Stable since Rust version 1.24.0'>1.24.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#779-789' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-7' class="method"><code id='from.v-7'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a>) -> <a class="struct" href="../../std/rc/struct.Rc.html" title="struct std::rc::Rc">Rc</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#785-788' title='goto source code'>[src]</a></h4><div class='docblock'><p>Converts a <a href="../ffi/struct.CString.html"><code>CString</code></a> into a <a href="../rc/struct.Rc.html"><code>Rc</code></a><code><CStr></code> without copying or allocating.</p> </div></div><h3 id='impl-From%3C%26%27_%20CStr%3E' class='impl'><code class='in-band'>impl<'_> <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><&'_ <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-From%3C%26%27_%20CStr%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1271-1275' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-8' class="method hidden"><code id='from.v-8'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: &<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>) -> <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1272-1274' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-Hash' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/hash/trait.Hash.html" title="trait std::hash::Hash">Hash</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Hash' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.hash' class="method hidden"><code id='hash.v'>fn <a href='../../std/hash/trait.Hash.html#tymethod.hash' class='fnname'>hash</a><__H: <a class="trait" href="../../std/hash/trait.Hasher.html" title="trait std::hash::Hasher">Hasher</a>>(&self, state: <a class="primitive" href="../primitive.reference.html">&mut </a>__H)</code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Feeds this value into the given [<code>Hasher</code>]. <a href="../../std/hash/trait.Hash.html#tymethod.hash">Read more</a></p> </div><h4 id='method.hash_slice' class="method"><code id='hash_slice.v'>fn <a href='../../std/hash/trait.Hash.html#method.hash_slice' class='fnname'>hash_slice</a><H>(data: <a class="primitive" href="../primitive.slice.html">&[Self]</a>, state: <a class="primitive" href="../primitive.reference.html">&mut </a>H) <span class="where fmt-newline">where<br> H: <a class="trait" href="../../std/hash/trait.Hasher.html" title="trait std::hash::Hasher">Hasher</a>, </span></code><div class='since' title='Stable since Rust version 1.3.0'>1.3.0</div><a class='srclink' href='../../src/core/hash/mod.rs.html#193-199' title='goto source code'>[src]</a></h4><div class='docblock'><p>Feeds a slice of this type into the given [<code>Hasher</code>]. <a href="../../std/hash/trait.Hash.html#method.hash_slice">Read more</a></p> </div></div><h3 id='impl-Drop' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/ops/trait.Drop.html" title="trait std::ops::Drop">Drop</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Drop' class='anchor'></a><div class='since' title='Stable since Rust version 1.13.0'>1.13.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#612-617' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.drop' class="method hidden"><code id='drop.v'>fn <a href='../../std/ops/trait.Drop.html#tymethod.drop' class='fnname'>drop</a>(&mut self)</code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#614-616' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Executes the destructor for this type. <a href="../../std/ops/trait.Drop.html#tymethod.drop">Read more</a></p> </div></div><h3 id='impl-Index%3CRangeFull%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/ops/trait.Index.html" title="trait std::ops::Index">Index</a><<a class="struct" href="../../std/ops/struct.RangeFull.html" title="struct std::ops::RangeFull">RangeFull</a>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Index%3CRangeFull%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1278-1285' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Output' class="type"><code id='Output.t'>type <a href='../../std/ops/trait.Index.html#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code></h4><div class='docblock'><p>The returned type after indexing.</p> </div><h4 id='method.index' class="method hidden"><code id='index.v'>fn <a href='../../std/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&self, _index: <a class="struct" href="../../std/ops/struct.RangeFull.html" title="struct std::ops::RangeFull">RangeFull</a>) -> &<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1282-1284' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the indexing (<code>container[index]</code>) operation.</p> </div></div><h3 id='impl-Clone' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Clone' class='anchor'></a><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.clone' class="method hidden"><code id='clone.v'>fn <a href='../../std/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#114' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="../../std/clone/trait.Clone.html#tymethod.clone">Read more</a></p> </div><h4 id='method.clone_from' class="method"><code id='clone_from.v'>fn <a href='../../std/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: <a class="primitive" href="../primitive.reference.html">&</a>Self)</code><a class='srclink' href='../../src/core/clone.rs.html#131-133' title='goto source code'>[src]</a></h4><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="../../std/clone/trait.Clone.html#method.clone_from">Read more</a></p> </div></div><h3 id='impl-AsRef%3CCStr%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/convert/trait.AsRef.html" title="trait std::convert::AsRef">AsRef</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-AsRef%3CCStr%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1296-1301' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.as_ref' class="method hidden"><code id='as_ref.v'>fn <a href='../../std/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&self) -> &<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#1298-1300' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-Default' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/default/trait.Default.html" title="trait std::default::Default">Default</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Default' class='anchor'></a><div class='since' title='Stable since Rust version 1.10.0'>1.10.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#670-676' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.default' class="method"><code id='default.v'>fn <a href='../../std/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -> <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#672-675' title='goto source code'>[src]</a></h4><div class='docblock'><p>Creates an empty <code>CString</code>.</p> </div></div><h3 id='impl-Borrow%3CCStr%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/borrow/trait.Borrow.html" title="trait std::borrow::Borrow">Borrow</a><<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a>> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Borrow%3CCStr%3E' class='anchor'></a><div class='since' title='Stable since Rust version 1.3.0'>1.3.0</div><a class='srclink' href='../../src/std/ffi/c_str.rs.html#679-682' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><code id='borrow.v'>fn <a href='../../std/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&self) -> &<a class="struct" href="../../std/ffi/struct.CStr.html" title="struct std::ffi::CStr">CStr</a></code><a class='srclink' href='../../src/std/ffi/c_str.rs.html#681' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="../../std/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p> </div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Send' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/marker/trait.Send.html" title="trait std::marker::Send">Send</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><code class='in-band'>impl <a class="trait" href="../../std/marker/trait.Sync.html" title="trait std::marker::Sync">Sync</a> for <a class="struct" href="../../std/ffi/struct.CString.html" title="struct std::ffi::CString">CString</a></code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-TryFrom' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a><T>, </span></code><a href='#impl-TryFrom' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#565-571' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='../../std/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="../../std/convert/enum.Infallible.html" title="enum std::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p> </div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='../../std/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><T, <T as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='../../src/core/convert.rs.html#568-570' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-From' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a> for T</code><a href='#impl-From' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#546-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from-9' class="method hidden"><code id='from.v-9'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -> T</code><a class='srclink' href='../../src/core/convert.rs.html#547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-TryInto' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/convert/trait.TryInto.html" title="trait std::convert::TryInto">TryInto</a> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><T>, </span></code><a href='#impl-TryInto' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#553-560' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='../../std/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = <U as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p> </div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='../../std/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><U, <U as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='../../src/core/convert.rs.html#557-559' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-Into' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><T>, </span></code><a href='#impl-Into' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#537-542' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='../../std/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -> U</code><a class='srclink' href='../../src/core/convert.rs.html#539-541' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-Borrow' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/borrow/trait.Borrow.html" title="trait std::borrow::Borrow">Borrow</a> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Borrow' class='anchor'></a><a class='srclink' href='../../src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow-1' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>>::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>>::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>R</span><span class="where fmt-newline">impl<W: <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>W</span></code></div></div><code id='borrow.v-1'>fn <a href='../../std/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&self) -> <a class="primitive" href="../primitive.reference.html">&</a>T</code><a class='srclink' href='../../src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="../../std/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p> </div></div><h3 id='impl-BorrowMut' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/borrow/trait.BorrowMut.html" title="trait std::borrow::BorrowMut">BorrowMut</a> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-BorrowMut' class='anchor'></a><a class='srclink' href='../../src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>>::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>>::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>R</span><span class="where fmt-newline">impl<W: <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>W</span></code></div></div><code id='borrow_mut.v'>fn <a href='../../std/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&mut self) -> <a class="primitive" href="../primitive.reference.html">&mut </a>T</code><a class='srclink' href='../../src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="../../std/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p> </div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/any/trait.Any.html" title="trait std::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='../../src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='../../std/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&self) -> <a class="struct" href="../../std/any/struct.TypeId.html" title="struct std::any::TypeId">TypeId</a></code><a class='srclink' href='../../src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="../../std/any/trait.Any.html#tymethod.type_id">Read more</a></p> </div></div><h3 id='impl-ToOwned' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/borrow/trait.ToOwned.html" title="trait std::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="../../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a>, </span></code><a href='#impl-ToOwned' class='anchor'></a><a class='srclink' href='../../src/alloc/borrow.rs.html#80-91' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Owned' class="type"><code id='Owned.t'>type <a href='../../std/borrow/trait.ToOwned.html#associatedtype.Owned' class="type">Owned</a> = T</code></h4><h4 id='method.to_owned' class="method hidden"><code id='to_owned.v'>fn <a href='../../std/borrow/trait.ToOwned.html#tymethod.to_owned' class='fnname'>to_owned</a>(&self) -> T</code><a class='srclink' href='../../src/alloc/borrow.rs.html#84-86' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="../../std/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p> </div><h4 id='method.clone_into' class="method hidden"><code id='clone_into.v'>fn <a href='../../std/borrow/trait.ToOwned.html#method.clone_into' class='fnname'>clone_into</a>(&self, target: <a class="primitive" href="../primitive.reference.html">&mut </a>T)</code><a class='srclink' href='../../src/alloc/borrow.rs.html#88-90' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code> <a href="https://github.com/rust-lang/rust/issues/41263">#41263</a>)</summary><p>recently added</p> </details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="../../std/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p> </div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "std";</script><script src="../../aliases.js"></script><script src="../../main1.35.0.js"></script><script defer src="../../search-index.js"></script></body></html>