oxipng/doc/bitflags/__core/string/struct.String.html
2016-05-04 10:41:29 -04:00

2118 lines
No EOL
238 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `String` struct in crate `bitflags`.">
<meta name="keywords" content="rust, rustlang, rust-lang, String">
<title>bitflags::__core::string::String - Rust</title>
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>string</a></p><script>window.sidebarCurrent = {name: 'String', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>string</a>::<wbr><a class='struct' href=''>String</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-3514' class='srclink' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html?gotosrc=3514' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct String {
// some fields omitted
}</pre><span class="since">1.0.0</span><div class='docblock'><p>A UTF-8 encoded, growable string.</p>
<p>The <code>String</code> type is the most common string type that has ownership over the
contents of the string. It has a close relationship with its borrowed
counterpart, the primitive <a href="../../std/primitive.str.html"><code>str</code></a>.</p>
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
<p>You can create a <code>String</code> from a literal string with <code>String::from</code>:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>hello</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;Hello, world!&quot;</span>);</pre>
<p>You can append a <a href="../../std/primitive.char.html"><code>char</code></a> to a <code>String</code> with the <a href="#method.push"><code>push()</code></a> method, and
append a <a href="../../std/primitive.str.html"><code>&amp;str</code></a> with the <a href="#method.push_str"><code>push_str()</code></a> method:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>hello</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;Hello, &quot;</span>);
<span class='ident'>hello</span>.<span class='ident'>push</span>(<span class='string'>&#39;w&#39;</span>);
<span class='ident'>hello</span>.<span class='ident'>push_str</span>(<span class='string'>&quot;orld!&quot;</span>);</pre>
<p>If you have a vector of UTF-8 bytes, you can create a <code>String</code> from it with
the <a href="#method.from_utf8"><code>from_utf8()</code></a> method:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// some bytes, in a vector</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>240</span>, <span class='number'>159</span>, <span class='number'>146</span>, <span class='number'>150</span>];
<span class='comment'>// We know these bytes are valid, so we&#39;ll use `unwrap()`.</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>sparkle_heart</span>).<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;💖&quot;</span>, <span class='ident'>sparkle_heart</span>);</pre>
<h1 id='utf-8' class='section-header'><a href='#utf-8'>UTF-8</a></h1>
<p><code>String</code>s are always valid UTF-8. This has a few implications, the first of
which is that if you need a non-UTF-8 string, consider <a href="../../std/ffi/struct.OsString.html"><code>OsString</code></a>. It is
similar, but without the UTF-8 constraint. The second implication is that
you cannot index into a <code>String</code>:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;hello&quot;</span>;
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;The first letter of s is {}&quot;</span>, <span class='ident'>s</span>[<span class='number'>0</span>]); <span class='comment'>// ERROR!!!</span></pre>
<p>Indexing is intended to be a constant-time operation, but UTF-8 encoding
does not allow us to do this. Furtheremore, it&#39;s not clear what sort of
thing the index should return: a byte, a codepoint, or a grapheme cluster.
The <a href="#method.as_bytes"><code>as_bytes()</code></a> and <a href="#method.chars"><code>chars()</code></a> methods return iterators over the first
two, respectively.</p>
<h1 id='deref' class='section-header'><a href='#deref'>Deref</a></h1>
<p><code>String</code>s implement <a href="../../std/ops/trait.Deref.html"><code>Deref</code></a><code>&lt;Target=str&gt;</code>, and so inherit all of <a href="../../std/primitive.str.html"><code>str</code></a>&#39;s
methods. In addition, this means that you can pass a <code>String</code> to any
function which takes a <a href="../../std/primitive.str.html"><code>&amp;str</code></a> by using an ampersand (<code>&amp;</code>):</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>fn</span> <span class='ident'>takes_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='ident'>str</span>) { }
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;Hello&quot;</span>);
<span class='ident'>takes_str</span>(<span class='kw-2'>&amp;</span><span class='ident'>s</span>);</pre>
<p>This will create a <a href="../../std/primitive.str.html"><code>&amp;str</code></a> from the <code>String</code> and pass it in. This
conversion is very inexpensive, and so generally, functions will accept
<a href="../../std/primitive.str.html"><code>&amp;str</code></a>s as arguments unless they need a <code>String</code> for some specific reason.</p>
<h1 id='representation' class='section-header'><a href='#representation'>Representation</a></h1>
<p>A <code>String</code> is made up of three components: a pointer to some bytes, a
length, and a capacity. The pointer points to an internal buffer <code>String</code>
uses to store its data. The length is the number of bytes currently stored
in the buffer, and the capacity is the size of the buffer in bytes. As such,
the length will always be less than or equal to the capacity.</p>
<p>This buffer is always stored on the heap.</p>
<p>You can look at these with the <a href="#method.as_ptr"><code>as_ptr()</code></a>, <a href="#method.len"><code>len()</code></a>, and <a href="#method.capacity"><code>capacity()</code></a>
methods:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>;
<span class='kw'>let</span> <span class='ident'>story</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;Once upon a time...&quot;</span>);
<span class='kw'>let</span> <span class='ident'>ptr</span> <span class='op'>=</span> <span class='ident'>story</span>.<span class='ident'>as_ptr</span>();
<span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>story</span>.<span class='ident'>len</span>();
<span class='kw'>let</span> <span class='ident'>capacity</span> <span class='op'>=</span> <span class='ident'>story</span>.<span class='ident'>capacity</span>();
<span class='comment'>// story has thirteen bytes</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>19</span>, <span class='ident'>len</span>);
<span class='comment'>// Now that we have our parts, we throw the story away.</span>
<span class='ident'>mem</span>::<span class='ident'>forget</span>(<span class='ident'>story</span>);
<span class='comment'>// We can re-build a String out of ptr, len, and capacity. This is all</span>
<span class='comment'>// unsafe because we are responsible for making sure the components are</span>
<span class='comment'>// valid:</span>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>String</span>::<span class='ident'>from_raw_parts</span>(<span class='ident'>ptr</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> _, <span class='ident'>len</span>, <span class='ident'>capacity</span>) } ;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;Once upon a time...&quot;</span>), <span class='ident'>s</span>);</pre>
<p>If a <code>String</code> has enough capacity, adding elements to it will not
re-allocate. For example, consider this program:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
<span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>5</span> {
<span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
}</pre>
<p>This will output the following:</p>
<pre><code class="language-text">0
5
10
20
20
40
</code></pre>
<p>At first, we have no memory allocated at all, but as we append to the
string, it increases its capacity appropriately. If we instead use the
<a href="#method.with_capacity"><code>with_capacity()</code></a> method to allocate the correct capacity initially:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>25</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
<span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>5</span> {
<span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
}</pre>
<p>We end up with a different output:</p>
<pre><code class="language-text">25
25
25
25
25
25
</code></pre>
<p>Here, there&#39;s no need to allocate more memory inside the loop.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='docblock'><p>Creates a new empty <code>String</code>.</p>
<p>Given that the <code>String</code> is empty, this will not allocate any initial
buffer. While that means that this initial operation is very
inexpensive, but may cause excessive allocation later, when you add
data. If you have an idea of how much data the <code>String</code> will hold,
consider the <a href="#method.with_capacity"><code>with_capacity()</code></a> method to prevent excessive
re-allocation.</p>
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();</pre>
</div><h4 id='method.with_capacity' class='method'><code>fn <a href='#method.with_capacity' class='fnname'>with_capacity</a>(capacity: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='docblock'><p>Creates a new empty <code>String</code> with a particular capacity.</p>
<p><code>String</code>s have an internal buffer to hold their data. The capacity is
the length of that buffer, and can be queried with the <a href="#method.capacity"><code>capacity()</code></a>
method. This method creates an empty <code>String</code>, but one with an initial
buffer that can hold <code>capacity</code> bytes. This is useful when you may be
appending a bunch of data to the <code>String</code>, reducing the number of
reallocations it needs to do.</p>
<p>If the given capacity is <code>0</code>, no allocation will occur, and this method
is identical to the <a href="#method.new"><code>new()</code></a> method.</p>
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='comment'>// The String contains no chars, even though it has capacity for more</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>len</span>(), <span class='number'>0</span>);
<span class='comment'>// These are all done without reallocating...</span>
<span class='kw'>let</span> <span class='ident'>cap</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>capacity</span>();
<span class='kw'>for</span> <span class='ident'>i</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>10</span> {
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);
}
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>(), <span class='ident'>cap</span>);
<span class='comment'>// ...but this may make the vector reallocate</span>
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);</pre>
</div><h4 id='method.from_utf8' class='method'><code>fn <a href='#method.from_utf8' class='fnname'>from_utf8</a>(vec: <a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>&gt;) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>, <a class='struct' href='../../../bitflags/__core/string/struct.FromUtf8Error.html' title='bitflags::__core::string::FromUtf8Error'>FromUtf8Error</a>&gt;</code></h4>
<div class='docblock'><p>Converts a vector of bytes to a <code>String</code>.</p>
<p>A string slice (<a href="../../std/primitive.str.html"><code>&amp;str</code></a>) is made of bytes (<a href="../../std/primitive.u8.html"><code>u8</code></a>), and a vector of bytes
(<a href="../../std/vec/struct.Vec.html"><code>Vec&lt;u8&gt;</code></a>) is made of bytes, so this function converts between the
two. Not all byte slices are valid <code>String</code>s, however: <code>String</code>
requires that it is valid UTF-8. <code>from_utf8()</code> checks to ensure that
the bytes are valid UTF-8, and then does the conversion.</p>
<p>If you are sure that the byte slice is valid UTF-8, and you don&#39;t want
to incur the overhead of the validity check, there is an unsafe version
of this function, <a href="struct.String.html#method.from_utf8_unchecked"><code>from_utf8_unchecked()</code></a>, which has the same behavior
but skips the check.</p>
<p>This method will take care to not copy the vector, for efficiency&#39;s
sake.</p>
<p>If you need a <code>&amp;str</code> instead of a <code>String</code>, consider
<a href="../../std/str/fn.from_utf8.html"><code>str::from_utf8()</code></a>.</p>
<h1 id='errors' class='section-header'><a href='#errors'>Errors</a></h1>
<p>Returns <code>Err</code> if the slice is not UTF-8 with a description as to why the
provided bytes are not UTF-8. The vector you moved in is also included.</p>
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// some bytes, in a vector</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>240</span>, <span class='number'>159</span>, <span class='number'>146</span>, <span class='number'>150</span>];
<span class='comment'>// We know these bytes are valid, so we&#39;ll use `unwrap()`.</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>sparkle_heart</span>).<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;💖&quot;</span>, <span class='ident'>sparkle_heart</span>);</pre>
<p>Incorrect bytes:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// some invalid bytes, in a vector</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>0</span>, <span class='number'>159</span>, <span class='number'>146</span>, <span class='number'>150</span>];
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>sparkle_heart</span>).<span class='ident'>is_err</span>());</pre>
<p>See the docs for <a href="struct.FromUtf8Error.html"><code>FromUtf8Error</code></a> for more details on what you can do
with this error.</p>
</div><h4 id='method.from_utf8_lossy' class='method'><code>fn <a href='#method.from_utf8_lossy' class='fnname'>from_utf8_lossy</a>(v: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;'a [</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a>) -&gt; <a class='enum' href='../../../bitflags/__core/borrow/enum.Cow.html' title='bitflags::__core::borrow::Cow'>Cow</a>&lt;'a, <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;</code></h4>
<div class='docblock'><p>Converts a slice of bytes to a string, including invalid characters.</p>
<p>Strings are made of bytes (<a href="../../std/primitive.u8.html"><code>u8</code></a>), and a slice of bytes
(<a href="../../std/primitive.slice.html"><code>&amp;[u8]</code></a>) is made of bytes, so this function converts
between the two. Not all byte slices are valid strings, however: strings
are required to be valid UTF-8. During this conversion,
<code>from_utf8_lossy()</code> will replace any invalid UTF-8 sequences with
<code>U+FFFD REPLACEMENT CHARACTER</code>, which looks like this: <20></p>
<p>If you are sure that the byte slice is valid UTF-8, and you don&#39;t want
to incur the overhead of the conversion, there is an unsafe version
of this function, <a href="struct.String.html#method.from_utf8_unchecked"><code>from_utf8_unchecked()</code></a>, which has the same behavior
but skips the checks.</p>
<p>This function returns a <a href="../../std/borrow/enum.Cow.html"><code>Cow&lt;&#39;a, str&gt;</code></a>. If our byte slice is invalid
UTF-8, then we need to insert the replacement characters, which will
change the size of the string, and hence, require a <code>String</code>. But if
it&#39;s already valid UTF-8, we don&#39;t need a new allocation. This return
type allows us to handle both cases.</p>
<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// some bytes, in a vector</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>240</span>, <span class='number'>159</span>, <span class='number'>146</span>, <span class='number'>150</span>];
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8_lossy</span>(<span class='kw-2'>&amp;</span><span class='ident'>sparkle_heart</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;💖&quot;</span>, <span class='ident'>sparkle_heart</span>);</pre>
<p>Incorrect bytes:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// some invalid bytes</span>
<span class='kw'>let</span> <span class='ident'>input</span> <span class='op'>=</span> <span class='string'>b&quot;Hello \xF0\x90\x80World&quot;</span>;
<span class='kw'>let</span> <span class='ident'>output</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8_lossy</span>(<span class='ident'>input</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;Hello <20>World&quot;</span>, <span class='ident'>output</span>);</pre>
</div><h4 id='method.from_utf16' class='method'><code>fn <a href='#method.from_utf16' class='fnname'>from_utf16</a>(v: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u16.html'>u16</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>, <a class='struct' href='../../../bitflags/__core/string/struct.FromUtf16Error.html' title='bitflags::__core::string::FromUtf16Error'>FromUtf16Error</a>&gt;</code></h4>
<div class='docblock'><p>Decode a UTF-16 encoded vector <code>v</code> into a <code>String</code>, returning <code>Err</code>
if <code>v</code> contains any invalid data.</p>
<h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// 𝄞music</span>
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='number'>0xD834</span>, <span class='number'>0xDD1E</span>, <span class='number'>0x006d</span>, <span class='number'>0x0075</span>,
<span class='number'>0x0073</span>, <span class='number'>0x0069</span>, <span class='number'>0x0063</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;𝄞music&quot;</span>),
<span class='ident'>String</span>::<span class='ident'>from_utf16</span>(<span class='ident'>v</span>).<span class='ident'>unwrap</span>());
<span class='comment'>// 𝄞mu&lt;invalid&gt;ic</span>
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='number'>0xD834</span>, <span class='number'>0xDD1E</span>, <span class='number'>0x006d</span>, <span class='number'>0x0075</span>,
<span class='number'>0xD800</span>, <span class='number'>0x0069</span>, <span class='number'>0x0063</span>];
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>String</span>::<span class='ident'>from_utf16</span>(<span class='ident'>v</span>).<span class='ident'>is_err</span>());</pre>
</div><h4 id='method.from_utf16_lossy' class='method'><code>fn <a href='#method.from_utf16_lossy' class='fnname'>from_utf16_lossy</a>(v: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u16.html'>u16</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a>) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='docblock'><p>Decode a UTF-16 encoded vector <code>v</code> into a string, replacing
invalid data with the replacement character (U+FFFD).</p>
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// 𝄞mus&lt;invalid&gt;ic&lt;invalid&gt;</span>
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='number'>0xD834</span>, <span class='number'>0xDD1E</span>, <span class='number'>0x006d</span>, <span class='number'>0x0075</span>,
<span class='number'>0x0073</span>, <span class='number'>0xDD1E</span>, <span class='number'>0x0069</span>, <span class='number'>0x0063</span>,
<span class='number'>0xD834</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;𝄞mus\u{FFFD}ic\u{FFFD}&quot;</span>),
<span class='ident'>String</span>::<span class='ident'>from_utf16_lossy</span>(<span class='ident'>v</span>));</pre>
</div><h4 id='method.from_raw_parts' class='method'><code>unsafe fn <a href='#method.from_raw_parts' class='fnname'>from_raw_parts</a>(buf: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.pointer.html'>*mut </a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>, length: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, capacity: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='docblock'><p>Creates a new <code>String</code> from a length, capacity, and pointer.</p>
<h1 id='safety' class='section-header'><a href='#safety'>Safety</a></h1>
<p>This is highly unsafe, due to the number of invariants that aren&#39;t
checked:</p>
<ul>
<li>The memory at <code>ptr</code> needs to have been previously allocated by the
same allocator the standard library uses.</li>
<li><code>length</code> needs to be less than or equal to <code>capacity</code>.</li>
<li><code>capacity</code> needs to be the correct value.</li>
</ul>
<p>Violating these may cause problems like corrupting the allocator&#39;s
internal datastructures.</p>
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>;
<span class='kw'>unsafe</span> {
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>let</span> <span class='ident'>ptr</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>as_ptr</span>();
<span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>len</span>();
<span class='kw'>let</span> <span class='ident'>capacity</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>capacity</span>();
<span class='ident'>mem</span>::<span class='ident'>forget</span>(<span class='ident'>s</span>);
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_raw_parts</span>(<span class='ident'>ptr</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> _, <span class='ident'>len</span>, <span class='ident'>capacity</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>), <span class='ident'>s</span>);
}</pre>
</div><h4 id='method.from_utf8_unchecked' class='method'><code>unsafe fn <a href='#method.from_utf8_unchecked' class='fnname'>from_utf8_unchecked</a>(bytes: <a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>&gt;) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='docblock'><p>Converts a vector of bytes to a <code>String</code> without checking that the
string contains valid UTF-8.</p>
<p>See the safe version, <a href="struct.String.html#method.from_utf8"><code>from_utf8()</code></a>, for more details.</p>
<h1 id='safety-1' class='section-header'><a href='#safety-1'>Safety</a></h1>
<p>This function is unsafe because it does not check that the bytes passed
to it are valid UTF-8. If this constraint is violated, it may cause
memory unsafety issues with future users of the <code>String</code>, as the rest of
the standard library assumes that <code>String</code>s are valid UTF-8.</p>
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='comment'>// some bytes, in a vector</span>
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>240</span>, <span class='number'>159</span>, <span class='number'>146</span>, <span class='number'>150</span>];
<span class='kw'>let</span> <span class='ident'>sparkle_heart</span> <span class='op'>=</span> <span class='kw'>unsafe</span> {
<span class='ident'>String</span>::<span class='ident'>from_utf8_unchecked</span>(<span class='ident'>sparkle_heart</span>)
};
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;💖&quot;</span>, <span class='ident'>sparkle_heart</span>);</pre>
</div><h4 id='method.into_bytes' class='method'><code>fn <a href='#method.into_bytes' class='fnname'>into_bytes</a>(self) -&gt; <a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>&gt;</code></h4>
<div class='docblock'><p>Converts a <code>String</code> into a byte vector.</p>
<p>This consumes the <code>String</code>, so we do not need to copy its contents.</p>
<h1 id='examples-9' class='section-header'><a href='#examples-9'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>into_bytes</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span>[<span class='number'>104</span>, <span class='number'>101</span>, <span class='number'>108</span>, <span class='number'>108</span>, <span class='number'>111</span>][..], <span class='kw-2'>&amp;</span><span class='ident'>bytes</span>[..]);</pre>
</div><h4 id='method.as_str' class='method'><code>fn <a href='#method.as_str' class='fnname'>as_str</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code><span class="since">1.7.0</span></h4>
<div class='docblock'><p>Extracts a string slice containing the entire string.</p>
</div><h4 id='method.as_mut_str' class='method'><code>fn <a href='#method.as_mut_str' class='fnname'>as_mut_str</a>(&amp;mut self) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code><span class="since">1.7.0</span></h4>
<div class='docblock'><p>Extracts a string slice containing the entire string.</p>
</div><h4 id='method.push_str' class='method'><code>fn <a href='#method.push_str' class='fnname'>push_str</a>(&amp;mut self, string: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>)</code></h4>
<div class='docblock'><p>Appends a given string slice onto the end of this <code>String</code>.</p>
<h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='string'>&quot;bar&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;foobar&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.capacity' class='method'><code>fn <a href='#method.capacity' class='fnname'>capacity</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Returns this <code>String</code>&#39;s capacity, in bytes.</p>
<h1 id='examples-11' class='section-header'><a href='#examples-11'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>10</span>);</pre>
</div><h4 id='method.reserve' class='method'><code>fn <a href='#method.reserve' class='fnname'>reserve</a>(&amp;mut self, additional: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>)</code></h4>
<div class='docblock'><p>Ensures that this <code>String</code>&#39;s capacity is at least <code>additional</code> bytes
larger than its length.</p>
<p>The capacity may be increased by more than <code>additional</code> bytes if it
chooses, to prevent frequent reallocations.</p>
<p>If you do not want this &quot;at least&quot; behavior, see the <a href="#method.reserve_exact"><code>reserve_exact()</code></a>
method.</p>
<h1 id='panics' class='section-header'><a href='#panics'>Panics</a></h1>
<p>Panics if the new capacity overflows <code>usize</code>.</p>
<h1 id='examples-12' class='section-header'><a href='#examples-12'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
<span class='ident'>s</span>.<span class='ident'>reserve</span>(<span class='number'>10</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>10</span>);</pre>
<p>This may not actually increase the capacity:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;b&#39;</span>);
<span class='comment'>// s now has a length of 2 and a capacity of 10</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>2</span>, <span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
<span class='comment'>// Since we already have an extra 8 capacity, calling this...</span>
<span class='ident'>s</span>.<span class='ident'>reserve</span>(<span class='number'>8</span>);
<span class='comment'>// ... doesn&#39;t actually increase.</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.reserve_exact' class='method'><code>fn <a href='#method.reserve_exact' class='fnname'>reserve_exact</a>(&amp;mut self, additional: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>)</code></h4>
<div class='docblock'><p>Ensures that this <code>String</code>&#39;s capacity is <code>additional</code> bytes
larger than its length.</p>
<p>Consider using the <a href="#method.reserve"><code>reserve()</code></a> method unless you absolutely know
better than the allocator.</p>
<h1 id='panics-1' class='section-header'><a href='#panics-1'>Panics</a></h1>
<p>Panics if the new capacity overflows <code>usize</code>.</p>
<h1 id='examples-13' class='section-header'><a href='#examples-13'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
<span class='ident'>s</span>.<span class='ident'>reserve_exact</span>(<span class='number'>10</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>10</span>);</pre>
<p>This may not actually increase the capacity:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;b&#39;</span>);
<span class='comment'>// s now has a length of 2 and a capacity of 10</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>2</span>, <span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
<span class='comment'>// Since we already have an extra 8 capacity, calling this...</span>
<span class='ident'>s</span>.<span class='ident'>reserve_exact</span>(<span class='number'>8</span>);
<span class='comment'>// ... doesn&#39;t actually increase.</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.shrink_to_fit' class='method'><code>fn <a href='#method.shrink_to_fit' class='fnname'>shrink_to_fit</a>(&amp;mut self)</code></h4>
<div class='docblock'><p>Shrinks the capacity of this <code>String</code> to match its length.</p>
<h1 id='examples-14' class='section-header'><a href='#examples-14'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>reserve</span>(<span class='number'>100</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>100</span>);
<span class='ident'>s</span>.<span class='ident'>shrink_to_fit</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>3</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.push' class='method'><code>fn <a href='#method.push' class='fnname'>push</a>(&amp;mut self, ch: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>)</code></h4>
<div class='docblock'><p>Appends the given <code>char</code> to the end of this <code>String</code>.</p>
<h1 id='examples-15' class='section-header'><a href='#examples-15'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;abc&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;1&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;2&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;3&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;abc123&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.as_bytes' class='method'><code>fn <a href='#method.as_bytes' class='fnname'>as_bytes</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a></code></h4>
<div class='docblock'><p>Returns a byte slice of this <code>String</code>&#39;s contents.</p>
<h1 id='examples-16' class='section-header'><a href='#examples-16'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span>[<span class='number'>104</span>, <span class='number'>101</span>, <span class='number'>108</span>, <span class='number'>108</span>, <span class='number'>111</span>], <span class='ident'>s</span>.<span class='ident'>as_bytes</span>());</pre>
</div><h4 id='method.truncate' class='method'><code>fn <a href='#method.truncate' class='fnname'>truncate</a>(&amp;mut self, new_len: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>)</code></h4>
<div class='docblock'><p>Shortens this <code>String</code> to the specified length.</p>
<p>If <code>new_len</code> is greater than the string&#39;s current length, this has no
effect.</p>
<h1 id='panics-2' class='section-header'><a href='#panics-2'>Panics</a></h1>
<p>Panics if <code>new_len</code> does not lie on a <a href="../../std/primitive.char.html"><code>char</code></a> boundary.</p>
<h1 id='examples-17' class='section-header'><a href='#examples-17'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>truncate</span>(<span class='number'>2</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;he&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.pop' class='method'><code>fn <a href='#method.pop' class='fnname'>pop</a>(&amp;mut self) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt;</code></h4>
<div class='docblock'><p>Removes the last character from the string buffer and returns it.</p>
<p>Returns <code>None</code> if this <code>String</code> is empty.</p>
<h1 id='examples-18' class='section-header'><a href='#examples-18'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>Some</span>(<span class='string'>&#39;o&#39;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>Some</span>(<span class='string'>&#39;o&#39;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>Some</span>(<span class='string'>&#39;f&#39;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>None</span>);</pre>
</div><h4 id='method.remove' class='method'><code>fn <a href='#method.remove' class='fnname'>remove</a>(&amp;mut self, idx: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a></code></h4>
<div class='docblock'><p>Removes a <code>char</code> from this <code>String</code> at a byte position and returns it.</p>
<p>This is an <code>O(n)</code> operation, as it requires copying every element in the
buffer.</p>
<h1 id='panics-3' class='section-header'><a href='#panics-3'>Panics</a></h1>
<p>Panics if <code>idx</code> is larger than or equal to the <code>String</code>&#39;s length,
or if it does not lie on a <a href="../../std/primitive.char.html"><code>char</code></a> boundary.</p>
<h1 id='examples-19' class='section-header'><a href='#examples-19'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>remove</span>(<span class='number'>0</span>), <span class='string'>&#39;f&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>remove</span>(<span class='number'>1</span>), <span class='string'>&#39;o&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>remove</span>(<span class='number'>0</span>), <span class='string'>&#39;o&#39;</span>);</pre>
</div><h4 id='method.insert' class='method'><code>fn <a href='#method.insert' class='fnname'>insert</a>(&amp;mut self, idx: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, ch: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>)</code></h4>
<div class='docblock'><p>Inserts a character into this <code>String</code> at a byte position.</p>
<p>This is an <code>O(n)</code> operation as it requires copying every element in the
buffer.</p>
<h1 id='panics-4' class='section-header'><a href='#panics-4'>Panics</a></h1>
<p>Panics if <code>idx</code> is larger than the <code>String</code>&#39;s length, or if it does not
lie on a <a href="../../std/primitive.char.html"><code>char</code></a> boundary.</p>
<h1 id='examples-20' class='section-header'><a href='#examples-20'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>3</span>);
<span class='ident'>s</span>.<span class='ident'>insert</span>(<span class='number'>0</span>, <span class='string'>&#39;f&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&#39;o&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>insert</span>(<span class='number'>2</span>, <span class='string'>&#39;o&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;foo&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.as_mut_vec' class='method'><code>unsafe fn <a href='#method.as_mut_vec' class='fnname'>as_mut_vec</a>(&amp;mut self) -&gt; &amp;mut <a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>&gt;</code></h4>
<div class='docblock'><p>Returns a mutable reference to the contents of this <code>String</code>.</p>
<h1 id='safety-2' class='section-header'><a href='#safety-2'>Safety</a></h1>
<p>This function is unsafe because it does not check that the bytes passed
to it are valid UTF-8. If this constraint is violated, it may cause
memory unsafety issues with future users of the <code>String</code>, as the rest of
the standard library assumes that <code>String</code>s are valid UTF-8.</p>
<h1 id='examples-21' class='section-header'><a href='#examples-21'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>unsafe</span> {
<span class='kw'>let</span> <span class='ident'>vec</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>as_mut_vec</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span>[<span class='number'>104</span>, <span class='number'>101</span>, <span class='number'>108</span>, <span class='number'>108</span>, <span class='number'>111</span>][..], <span class='kw-2'>&amp;</span><span class='ident'>vec</span>[..]);
<span class='ident'>vec</span>.<span class='ident'>reverse</span>();
}
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='string'>&quot;olleh&quot;</span>);</pre>
</div><h4 id='method.len' class='method'><code>fn <a href='#method.len' class='fnname'>len</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Returns the length of this <code>String</code>, in bytes.</p>
<h1 id='examples-22' class='section-header'><a href='#examples-22'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>len</span>(), <span class='number'>3</span>);</pre>
</div><h4 id='method.is_empty' class='method'><code>fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Returns <code>true</code> if this <code>String</code> has a length of zero.</p>
<p>Returns <code>false</code> otherwise.</p>
<h1 id='examples-23' class='section-header'><a href='#examples-23'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>v</span>.<span class='ident'>is_empty</span>());
<span class='ident'>v</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>v</span>.<span class='ident'>is_empty</span>());</pre>
</div><h4 id='method.clear' class='method'><code>fn <a href='#method.clear' class='fnname'>clear</a>(&amp;mut self)</code></h4>
<div class='docblock'><p>Truncates this <code>String</code>, removing all contents.</p>
<p>While this means the <code>String</code> will have a length of zero, it does not
touch its capacity.</p>
<h1 id='examples-24' class='section-header'><a href='#examples-24'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>clear</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>is_empty</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>0</span>, <span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>3</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.drain' class='method'><code>fn <a href='#method.drain' class='fnname'>drain</a>&lt;R&gt;(&amp;mut self, range: R) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.Drain.html' title='bitflags::__core::string::Drain'>Drain</a> <span class='where'>where R: <a class='trait' href='https://doc.rust-lang.org/nightly/collections/range/trait.RangeArgument.html' title='collections::range::RangeArgument'>RangeArgument</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;</span></code><span class="since">1.6.0</span></h4>
<div class='docblock'><p>Create a draining iterator that removes the specified range in the string
and yields the removed chars.</p>
<p>Note: The element range is removed even if the iterator is not
consumed until the end.</p>
<h1 id='panics-5' class='section-header'><a href='#panics-5'>Panics</a></h1>
<p>Panics if the starting point or end point do not lie on a <a href="../../std/primitive.char.html"><code>char</code></a>
boundary, or if they&#39;re out of bounds.</p>
<h1 id='examples-25' class='section-header'><a href='#examples-25'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;α is alpha, β is beta&quot;</span>);
<span class='kw'>let</span> <span class='ident'>beta_offset</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>find</span>(<span class='string'>&#39;β&#39;</span>).<span class='ident'>unwrap_or</span>(<span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='comment'>// Remove the range up until the β from the string</span>
<span class='kw'>let</span> <span class='ident'>t</span>: <span class='ident'>String</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>drain</span>(..<span class='ident'>beta_offset</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>t</span>, <span class='string'>&quot;α is alpha, &quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='string'>&quot;β is beta&quot;</span>);
<span class='comment'>// A full range clears the string</span>
<span class='ident'>s</span>.<span class='ident'>drain</span>(..);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='string'>&quot;&quot;</span>);</pre>
</div><h4 id='method.into_boxed_str' class='method'><code>fn <a href='#method.into_boxed_str' class='fnname'>into_boxed_str</a>(self) -&gt; <a class='struct' href='../../../bitflags/__core/boxed/struct.Box.html' title='bitflags::__core::boxed::Box'>Box</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;</code><span class="since">1.4.0</span></h4>
<div class='docblock'><p>Converts this <code>String</code> into a <code>Box&lt;str&gt;</code>.</p>
<p>This will drop any excess capacity.</p>
<h1 id='examples-26' class='section-header'><a href='#examples-26'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>into_boxed_str</span>();</pre>
</div></div><h2 id='deref-methods'>Methods from <a class='trait' href='../../../bitflags/__core/ops/trait.Deref.html' title='bitflags::__core::ops::Deref'>Deref</a>&lt;Target=<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;</h2><div class='impl-items'><h4 id='method.len-1' class='method'><code>fn <a href='#method.len-1' class='fnname'>len</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Returns the length of <code>self</code>.</p>
<p>This length is in bytes, not <a href="primitive.char.html"><code>char</code></a>s or graphemes. In other words,
it may not be what a human considers the length of the string.</p>
<h1 id='examples-27' class='section-header'><a href='#examples-27'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='string'>&quot;foo&quot;</span>.<span class='ident'>len</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>3</span>, <span class='ident'>len</span>);
<span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='string'>&quot;ƒoo&quot;</span>.<span class='ident'>len</span>(); <span class='comment'>// fancy f!</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>4</span>, <span class='ident'>len</span>);</pre>
</div><h4 id='method.is_empty-1' class='method'><code>fn <a href='#method.is_empty-1' class='fnname'>is_empty</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Returns true if this slice has a length of zero bytes.</p>
<h1 id='examples-28' class='section-header'><a href='#examples-28'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>is_empty</span>());
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;not empty&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>s</span>.<span class='ident'>is_empty</span>());</pre>
</div><h4 id='method.is_char_boundary' class='method'><code>fn <a href='#method.is_char_boundary' class='fnname'>is_char_boundary</a>(&amp;self, index: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code><span class="since">1.9.0</span></h4>
<div class='docblock'><p>Checks that <code>index</code>-th byte lies at the start and/or end of a
UTF-8 code point sequence.</p>
<p>The start and end of the string (when <code>index == self.len()</code>) are
considered to be
boundaries.</p>
<p>Returns <code>false</code> if <code>index</code> is greater than <code>self.len()</code>.</p>
<h1 id='examples-29' class='section-header'><a href='#examples-29'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>is_char_boundary</span>(<span class='number'>0</span>));
<span class='comment'>// start of `老`</span>
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>is_char_boundary</span>(<span class='number'>6</span>));
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>is_char_boundary</span>(<span class='ident'>s</span>.<span class='ident'>len</span>()));
<span class='comment'>// second byte of `ö`</span>
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>s</span>.<span class='ident'>is_char_boundary</span>(<span class='number'>2</span>));
<span class='comment'>// third byte of `老`</span>
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>s</span>.<span class='ident'>is_char_boundary</span>(<span class='number'>8</span>));</pre>
</div><h4 id='method.as_bytes-1' class='method'><code>fn <a href='#method.as_bytes-1' class='fnname'>as_bytes</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a></code></h4>
<div class='docblock'><p>Converts a string slice to a byte slice.</p>
<h1 id='examples-30' class='section-header'><a href='#examples-30'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='string'>&quot;bors&quot;</span>.<span class='ident'>as_bytes</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>b&quot;bors&quot;</span>, <span class='ident'>bytes</span>);</pre>
</div><h4 id='method.as_ptr' class='method'><code>fn <a href='#method.as_ptr' class='fnname'>as_ptr</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.pointer.html'>*const </a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a></code></h4>
<div class='docblock'><p>Converts a string slice to a raw pointer.</p>
<p>As string slices are a slice of bytes, the raw pointer points to a
<a href="primitive.u8.html"><code>u8</code></a>. This pointer will be pointing to the first byte of the string
slice.</p>
<h1 id='examples-31' class='section-header'><a href='#examples-31'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Hello&quot;</span>;
<span class='kw'>let</span> <span class='ident'>ptr</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>as_ptr</span>();</pre>
</div><h4 id='method.slice_unchecked' class='method'><code>unsafe fn <a href='#method.slice_unchecked' class='fnname'>slice_unchecked</a>(&amp;self, begin: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, end: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='docblock'><p>Creates a string slice from another string slice, bypassing safety
checks.</p>
<p>This new slice goes from <code>begin</code> to <code>end</code>, including <code>begin</code> but
excluding <code>end</code>.</p>
<p>To get a mutable string slice instead, see the
<a href="#method.slice_mut_unchecked"><code>slice_mut_unchecked()</code></a> method.</p>
<h1 id='safety-3' class='section-header'><a href='#safety-3'>Safety</a></h1>
<p>Callers of this function are responsible that three preconditions are
satisfied:</p>
<ul>
<li><code>begin</code> must come before <code>end</code>.</li>
<li><code>begin</code> and <code>end</code> must be byte positions within the string slice.</li>
<li><code>begin</code> and <code>end</code> must lie on UTF-8 sequence boundaries.</li>
</ul>
<h1 id='examples-32' class='section-header'><a href='#examples-32'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='kw'>unsafe</span> {
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>, <span class='ident'>s</span>.<span class='ident'>slice_unchecked</span>(<span class='number'>0</span>, <span class='number'>21</span>));
}
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Hello, world!&quot;</span>;
<span class='kw'>unsafe</span> {
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;world&quot;</span>, <span class='ident'>s</span>.<span class='ident'>slice_unchecked</span>(<span class='number'>7</span>, <span class='number'>12</span>));
}</pre>
</div><h4 id='method.slice_mut_unchecked' class='method'><code>unsafe fn <a href='#method.slice_mut_unchecked' class='fnname'>slice_mut_unchecked</a>(&amp;mut self, begin: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, end: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code><span class="since">1.5.0</span></h4>
<div class='docblock'><p>Creates a string slice from another string slice, bypassing safety
checks.</p>
<p>This new slice goes from <code>begin</code> to <code>end</code>, including <code>begin</code> but
excluding <code>end</code>.</p>
<p>To get an immutable string slice instead, see the
<a href="#method.slice_unchecked"><code>slice_unchecked()</code></a> method.</p>
<h1 id='safety-4' class='section-header'><a href='#safety-4'>Safety</a></h1>
<p>Callers of this function are responsible that three preconditions are
satisfied:</p>
<ul>
<li><code>begin</code> must come before <code>end</code>.</li>
<li><code>begin</code> and <code>end</code> must be byte positions within the string slice.</li>
<li><code>begin</code> and <code>end</code> must lie on UTF-8 sequence boundaries.</li>
</ul>
</div><h4 id='method.char_range_at' class='method'><code>fn <a href='#method.char_range_at' class='fnname'>char_range_at</a>(&amp;self, start: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.CharRange.html' title='bitflags::__core::str::CharRange'>CharRange</a></code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.9.0<p>: use slicing plus chars() plus len_utf8</p>
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>str_char</code>)<p>: use slicing plus chars() plus len_utf8</p>
</em></div><div class='docblock'><p>Given a byte position, returns the next <code>char</code> and its index.</p>
<h1 id='panics-6' class='section-header'><a href='#panics-6'>Panics</a></h1>
<p>If <code>i</code> is greater than or equal to the length of the string.
If <code>i</code> is not the index of the beginning of a valid UTF-8 sequence.</p>
<h1 id='examples-33' class='section-header'><a href='#examples-33'>Examples</a></h1>
<p>This example manually iterates through the code points of a string;
this should normally be
done by <code>.chars()</code> or <code>.char_indices()</code>.</p>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>str_char</span>)]</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>deprecated</span>)]</span>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>CharRange</span>;
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;中华Việt Nam&quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='number'>0</span>;
<span class='kw'>while</span> <span class='ident'>i</span> <span class='op'>&lt;</span> <span class='ident'>s</span>.<span class='ident'>len</span>() {
<span class='kw'>let</span> <span class='ident'>CharRange</span> {<span class='ident'>ch</span>, <span class='ident'>next</span>} <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>char_range_at</span>(<span class='ident'>i</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}: {}&quot;</span>, <span class='ident'>i</span>, <span class='ident'>ch</span>);
<span class='ident'>i</span> <span class='op'>=</span> <span class='ident'>next</span>;
}</pre>
<p>This outputs:</p>
<pre><code class="language-text">0: 中
3: 华
6: V
7: i
8: e
9:
11:
13: t
14:
15: N
16: a
17: m
</code></pre>
</div><h4 id='method.char_range_at_reverse' class='method'><code>fn <a href='#method.char_range_at_reverse' class='fnname'>char_range_at_reverse</a>(&amp;self, start: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.CharRange.html' title='bitflags::__core::str::CharRange'>CharRange</a></code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.9.0<p>: use slicing plus chars().rev() plus len_utf8</p>
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>str_char</code>)<p>: use slicing plus chars().rev() plus len_utf8</p>
</em></div><div class='docblock'><p>Given a byte position, returns the previous <code>char</code> and its position.</p>
<p>Note that Unicode has many features, such as combining marks, ligatures,
and direction marks, that need to be taken into account to correctly reverse a string.</p>
<p>Returns 0 for next index if called on start index 0.</p>
<h1 id='panics-7' class='section-header'><a href='#panics-7'>Panics</a></h1>
<p>If <code>i</code> is greater than the length of the string.
If <code>i</code> is not an index following a valid UTF-8 sequence.</p>
<h1 id='examples-34' class='section-header'><a href='#examples-34'>Examples</a></h1>
<p>This example manually iterates through the code points of a string;
this should normally be
done by <code>.chars().rev()</code> or <code>.char_indices()</code>.</p>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>str_char</span>)]</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>deprecated</span>)]</span>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>CharRange</span>;
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;中华Việt Nam&quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>len</span>();
<span class='kw'>while</span> <span class='ident'>i</span> <span class='op'>&gt;</span> <span class='number'>0</span> {
<span class='kw'>let</span> <span class='ident'>CharRange</span> {<span class='ident'>ch</span>, <span class='ident'>next</span>} <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>char_range_at_reverse</span>(<span class='ident'>i</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}: {}&quot;</span>, <span class='ident'>i</span>, <span class='ident'>ch</span>);
<span class='ident'>i</span> <span class='op'>=</span> <span class='ident'>next</span>;
}</pre>
<p>This outputs:</p>
<pre><code class="language-text">18: m
17: a
16: N
15:
14: t
13:
11:
9: e
8: i
7: V
6: 华
3: 中
</code></pre>
</div><h4 id='method.char_at' class='method'><code>fn <a href='#method.char_at' class='fnname'>char_at</a>(&amp;self, i: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a></code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.9.0<p>: use slicing plus chars()</p>
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>str_char</code>)<p>: use slicing plus chars()</p>
</em></div><div class='docblock'><p>Given a byte position, returns the <code>char</code> at that position.</p>
<h1 id='panics-8' class='section-header'><a href='#panics-8'>Panics</a></h1>
<p>If <code>i</code> is greater than or equal to the length of the string.
If <code>i</code> is not the index of the beginning of a valid UTF-8 sequence.</p>
<h1 id='examples-35' class='section-header'><a href='#examples-35'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>str_char</span>)]</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>deprecated</span>)]</span>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;abπc&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>char_at</span>(<span class='number'>1</span>), <span class='string'>&#39;b&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>char_at</span>(<span class='number'>2</span>), <span class='string'>&#39;π&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>char_at</span>(<span class='number'>4</span>), <span class='string'>&#39;c&#39;</span>);</pre>
</div><h4 id='method.char_at_reverse' class='method'><code>fn <a href='#method.char_at_reverse' class='fnname'>char_at_reverse</a>(&amp;self, i: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a></code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.9.0<p>: use slicing plus chars().rev()</p>
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>str_char</code>)<p>: use slicing plus chars().rev()</p>
</em></div><div class='docblock'><p>Given a byte position, returns the <code>char</code> at that position, counting
from the end.</p>
<h1 id='panics-9' class='section-header'><a href='#panics-9'>Panics</a></h1>
<p>If <code>i</code> is greater than the length of the string.
If <code>i</code> is not an index following a valid UTF-8 sequence.</p>
<h1 id='examples-36' class='section-header'><a href='#examples-36'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>str_char</span>)]</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>deprecated</span>)]</span>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;abπc&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>char_at_reverse</span>(<span class='number'>1</span>), <span class='string'>&#39;a&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>char_at_reverse</span>(<span class='number'>2</span>), <span class='string'>&#39;b&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>char_at_reverse</span>(<span class='number'>3</span>), <span class='string'>&#39;π&#39;</span>);</pre>
</div><h4 id='method.slice_shift_char' class='method'><code>fn <a href='#method.slice_shift_char' class='fnname'>slice_shift_char</a>(&amp;self) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>, &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt;</code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.9.0<p>: use chars() plus Chars::as_str</p>
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>str_char</code>)<p>: use chars() plus Chars::as_str</p>
</em></div><div class='docblock'><p>Retrieves the first <code>char</code> from a <code>&amp;str</code> and returns it.</p>
<p>Note that a single Unicode character (grapheme cluster)
can be composed of multiple <code>char</code>s.</p>
<p>This does not allocate a new string; instead, it returns a slice that
points one code point beyond the code point that was shifted.</p>
<p><code>None</code> is returned if the slice is empty.</p>
<h1 id='examples-37' class='section-header'><a href='#examples-37'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>str_char</span>)]</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>deprecated</span>)]</span>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Łódź&quot;</span>; <span class='comment'>// \u{141}o\u{301}dz\u{301}</span>
<span class='kw'>let</span> (<span class='ident'>c</span>, <span class='ident'>s1</span>) <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>slice_shift_char</span>().<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>c</span>, <span class='string'>&#39;Ł&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s1</span>, <span class='string'>&quot;ódź&quot;</span>);
<span class='kw'>let</span> (<span class='ident'>c</span>, <span class='ident'>s2</span>) <span class='op'>=</span> <span class='ident'>s1</span>.<span class='ident'>slice_shift_char</span>().<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>c</span>, <span class='string'>&#39;o&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s2</span>, <span class='string'>&quot;\u{301}dz\u{301}&quot;</span>);</pre>
</div><h4 id='method.split_at' class='method'><code>fn <a href='#method.split_at' class='fnname'>split_at</a>(&amp;self, mid: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>&amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>, &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a></code><span class="since">1.4.0</span></h4>
<div class='docblock'><p>Divide one string slice into two at an index.</p>
<p>The argument, <code>mid</code>, should be a byte offset from the start of the
string. It must also be on the boundary of a UTF-8 code point.</p>
<p>The two slices returned go from the start of the string slice to <code>mid</code>,
and from <code>mid</code> to the end of the string slice.</p>
<p>To get mutable string slices instead, see the <a href="#method.split_at_mut"><code>split_at_mut()</code></a>
method.</p>
<h1 id='panics-10' class='section-header'><a href='#panics-10'>Panics</a></h1>
<p>Panics if <code>mid</code> is not on a UTF-8 code point boundary, or if it is
beyond the last code point of the string slice.</p>
<h1 id='examples-38' class='section-header'><a href='#examples-38'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Per Martin-Löf&quot;</span>;
<span class='kw'>let</span> (<span class='ident'>first</span>, <span class='ident'>last</span>) <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>split_at</span>(<span class='number'>3</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;Per&quot;</span>, <span class='ident'>first</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot; Martin-Löf&quot;</span>, <span class='ident'>last</span>);</pre>
</div><h4 id='method.split_at_mut' class='method'><code>fn <a href='#method.split_at_mut' class='fnname'>split_at_mut</a>(&amp;mut self, mid: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>&amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>, &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a></code><span class="since">1.4.0</span></h4>
<div class='docblock'><p>Divide one mutable string slice into two at an index.</p>
<p>The argument, <code>mid</code>, should be a byte offset from the start of the
string. It must also be on the boundary of a UTF-8 code point.</p>
<p>The two slices returned go from the start of the string slice to <code>mid</code>,
and from <code>mid</code> to the end of the string slice.</p>
<p>To get immutable string slices instead, see the <a href="#method.split_at"><code>split_at()</code></a> method.</p>
<h1 id='panics-11' class='section-header'><a href='#panics-11'>Panics</a></h1>
<p>Panics if <code>mid</code> is not on a UTF-8 code point boundary, or if it is
beyond the last code point of the string slice.</p>
<h1 id='examples-39' class='section-header'><a href='#examples-39'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Per Martin-Löf&quot;</span>.<span class='ident'>to_string</span>();
<span class='kw'>let</span> (<span class='ident'>first</span>, <span class='ident'>last</span>) <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>split_at_mut</span>(<span class='number'>3</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;Per&quot;</span>, <span class='ident'>first</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot; Martin-Löf&quot;</span>, <span class='ident'>last</span>);</pre>
</div><h4 id='method.chars' class='method'><code>fn <a href='#method.chars' class='fnname'>chars</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.Chars.html' title='bitflags::__core::str::Chars'>Chars</a></code></h4>
<div class='docblock'><p>Returns an iterator over the <code>char</code>s of a string slice.</p>
<p>As a string slice consists of valid UTF-8, we can iterate through a
string slice by <a href="primitive.char.html"><code>char</code></a>. This method returns such an iterator.</p>
<p>It&#39;s important to remember that <a href="primitive.char.html"><code>char</code></a> represents a Unicode Scalar
Value, and may not match your idea of what a &#39;character&#39; is. Iteration
over grapheme clusters may be what you actually want.</p>
<h1 id='examples-40' class='section-header'><a href='#examples-40'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>word</span> <span class='op'>=</span> <span class='string'>&quot;goodbye&quot;</span>;
<span class='kw'>let</span> <span class='ident'>count</span> <span class='op'>=</span> <span class='ident'>word</span>.<span class='ident'>chars</span>().<span class='ident'>count</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>7</span>, <span class='ident'>count</span>);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>chars</span> <span class='op'>=</span> <span class='ident'>word</span>.<span class='ident'>chars</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;g&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;o&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;o&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;d&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;b&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;y&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;e&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>chars</span>.<span class='ident'>next</span>());</pre>
<p>Remember, <a href="primitive.char.html"><code>char</code></a>s may not match your human intuition about characters:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>y</span> <span class='op'>=</span> <span class='string'>&quot;&quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>chars</span> <span class='op'>=</span> <span class='ident'>y</span>.<span class='ident'>chars</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;y&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>()); <span class='comment'>// not &#39;&#39;</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;\u{0306}&#39;</span>), <span class='ident'>chars</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>chars</span>.<span class='ident'>next</span>());</pre>
</div><h4 id='method.char_indices' class='method'><code>fn <a href='#method.char_indices' class='fnname'>char_indices</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.CharIndices.html' title='bitflags::__core::str::CharIndices'>CharIndices</a></code></h4>
<div class='docblock'><p>Returns an iterator over the <a href="primitive.char.html"><code>char</code></a>s of a string slice, and their
positions.</p>
<p>As a string slice consists of valid UTF-8, we can iterate through a
string slice by <a href="primitive.char.html"><code>char</code></a>. This method returns an iterator of both
these <a href="primitive.char.html"><code>char</code></a>s, as well as their byte positions.</p>
<p>The iterator yields tuples. The position is first, the <a href="primitive.char.html"><code>char</code></a> is
second.</p>
<h1 id='examples-41' class='section-header'><a href='#examples-41'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>word</span> <span class='op'>=</span> <span class='string'>&quot;goodbye&quot;</span>;
<span class='kw'>let</span> <span class='ident'>count</span> <span class='op'>=</span> <span class='ident'>word</span>.<span class='ident'>char_indices</span>().<span class='ident'>count</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>7</span>, <span class='ident'>count</span>);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>char_indices</span> <span class='op'>=</span> <span class='ident'>word</span>.<span class='ident'>char_indices</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>0</span>, <span class='string'>&#39;g&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>1</span>, <span class='string'>&#39;o&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>2</span>, <span class='string'>&#39;o&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>3</span>, <span class='string'>&#39;d&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>4</span>, <span class='string'>&#39;b&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>5</span>, <span class='string'>&#39;y&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>6</span>, <span class='string'>&#39;e&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>char_indices</span>.<span class='ident'>next</span>());</pre>
<p>Remember, <a href="primitive.char.html"><code>char</code></a>s may not match your human intuition about characters:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>y</span> <span class='op'>=</span> <span class='string'>&quot;&quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>char_indices</span> <span class='op'>=</span> <span class='ident'>y</span>.<span class='ident'>char_indices</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>0</span>, <span class='string'>&#39;y&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>()); <span class='comment'>// not (0, &#39;&#39;)</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>((<span class='number'>1</span>, <span class='string'>&#39;\u{0306}&#39;</span>)), <span class='ident'>char_indices</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>char_indices</span>.<span class='ident'>next</span>());</pre>
</div><h4 id='method.bytes' class='method'><code>fn <a href='#method.bytes' class='fnname'>bytes</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.Bytes.html' title='bitflags::__core::str::Bytes'>Bytes</a></code></h4>
<div class='docblock'><p>An iterator over the bytes of a string slice.</p>
<p>As a string slice consists of a sequence of bytes, we can iterate
through a string slice by byte. This method returns such an iterator.</p>
<h1 id='examples-42' class='section-header'><a href='#examples-42'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='string'>&quot;bors&quot;</span>.<span class='ident'>bytes</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>b&#39;b&#39;</span>), <span class='ident'>bytes</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>b&#39;o&#39;</span>), <span class='ident'>bytes</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>b&#39;r&#39;</span>), <span class='ident'>bytes</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>b&#39;s&#39;</span>), <span class='ident'>bytes</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>bytes</span>.<span class='ident'>next</span>());</pre>
</div><h4 id='method.split_whitespace' class='method'><code>fn <a href='#method.split_whitespace' class='fnname'>split_whitespace</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.SplitWhitespace.html' title='bitflags::__core::str::SplitWhitespace'>SplitWhitespace</a></code><span class="since">1.1.0</span></h4>
<div class='docblock'><p>Split a string slice by whitespace.</p>
<p>The iterator returned will return string slices that are sub-slices of
the original string slice, separated by any amount of whitespace.</p>
<p>&#39;Whitespace&#39; is defined according to the terms of the Unicode Derived
Core Property <code>White_Space</code>.</p>
<h1 id='examples-43' class='section-header'><a href='#examples-43'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>iter</span> <span class='op'>=</span> <span class='string'>&quot;A few words&quot;</span>.<span class='ident'>split_whitespace</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;A&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;few&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;words&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>iter</span>.<span class='ident'>next</span>());</pre>
<p>All kinds of whitespace are considered:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>iter</span> <span class='op'>=</span> <span class='string'>&quot; Mary had\ta\u{2009}little \n\t lamb&quot;</span>.<span class='ident'>split_whitespace</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;Mary&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;had&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;a&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;little&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;lamb&quot;</span>), <span class='ident'>iter</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>iter</span>.<span class='ident'>next</span>());</pre>
</div><h4 id='method.lines' class='method'><code>fn <a href='#method.lines' class='fnname'>lines</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.Lines.html' title='bitflags::__core::str::Lines'>Lines</a></code></h4>
<div class='docblock'><p>An iterator over the lines of a string, as string slices.</p>
<p>Lines are ended with either a newline (<code>\n</code>) or a carriage return with
a line feed (<code>\r\n</code>).</p>
<p>The final line ending is optional.</p>
<h1 id='examples-44' class='section-header'><a href='#examples-44'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>text</span> <span class='op'>=</span> <span class='string'>&quot;foo\r\nbar\n\nbaz\n&quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>lines</span> <span class='op'>=</span> <span class='ident'>text</span>.<span class='ident'>lines</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;foo&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;bar&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;baz&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>lines</span>.<span class='ident'>next</span>());</pre>
<p>The final line ending isn&#39;t required:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>text</span> <span class='op'>=</span> <span class='string'>&quot;foo\nbar\n\r\nbaz&quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>lines</span> <span class='op'>=</span> <span class='ident'>text</span>.<span class='ident'>lines</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;foo&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;bar&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&quot;baz&quot;</span>), <span class='ident'>lines</span>.<span class='ident'>next</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>lines</span>.<span class='ident'>next</span>());</pre>
</div><h4 id='method.lines_any' class='method'><code>fn <a href='#method.lines_any' class='fnname'>lines_any</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.LinesAny.html' title='bitflags::__core::str::LinesAny'>LinesAny</a></code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.4.0<p>: use lines() instead now</p>
</em></div><div class='docblock'><p>An iterator over the lines of a string.</p>
</div><h4 id='method.utf16_units' class='method'><code>fn <a href='#method.utf16_units' class='fnname'>utf16_units</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.EncodeUtf16.html' title='bitflags::__core::str::EncodeUtf16'>EncodeUtf16</a></code></h4>
<div class='stability'><em class='stab deprecated'>Deprecated since 1.8.0<p>: renamed to encode_utf16</p>
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>str_utf16</code>)<p>: renamed to encode_utf16</p>
</em></div><div class='docblock'><p>Returns an iterator of <code>u16</code> over the string encoded as UTF-16.</p>
</div><h4 id='method.encode_utf16' class='method'><code>fn <a href='#method.encode_utf16' class='fnname'>encode_utf16</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.EncodeUtf16.html' title='bitflags::__core::str::EncodeUtf16'>EncodeUtf16</a></code><span class="since">1.8.0</span></h4>
<div class='docblock'><p>Returns an iterator of <code>u16</code> over the string encoded as UTF-16.</p>
</div><h4 id='method.contains' class='method'><code>fn <a href='#method.contains' class='fnname'>contains</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns <code>true</code> if the given pattern matches a sub-slice of
this string slice.</p>
<p>Returns <code>false</code> if it does not.</p>
<h1 id='examples-45' class='section-header'><a href='#examples-45'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>bananas</span> <span class='op'>=</span> <span class='string'>&quot;bananas&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>bananas</span>.<span class='ident'>contains</span>(<span class='string'>&quot;nana&quot;</span>));
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>bananas</span>.<span class='ident'>contains</span>(<span class='string'>&quot;apples&quot;</span>));</pre>
</div><h4 id='method.starts_with' class='method'><code>fn <a href='#method.starts_with' class='fnname'>starts_with</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns <code>true</code> if the given pattern matches a prefix of this
string slice.</p>
<p>Returns <code>false</code> if it does not.</p>
<h1 id='examples-46' class='section-header'><a href='#examples-46'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>bananas</span> <span class='op'>=</span> <span class='string'>&quot;bananas&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>bananas</span>.<span class='ident'>starts_with</span>(<span class='string'>&quot;bana&quot;</span>));
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>bananas</span>.<span class='ident'>starts_with</span>(<span class='string'>&quot;nana&quot;</span>));</pre>
</div><h4 id='method.ends_with' class='method'><code>fn <a href='#method.ends_with' class='fnname'>ends_with</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns <code>true</code> if the given pattern matches a suffix of this
string slice.</p>
<p>Returns <code>false</code> if it does not.</p>
<h1 id='examples-47' class='section-header'><a href='#examples-47'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>bananas</span> <span class='op'>=</span> <span class='string'>&quot;bananas&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>bananas</span>.<span class='ident'>ends_with</span>(<span class='string'>&quot;anas&quot;</span>));
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>bananas</span>.<span class='ident'>ends_with</span>(<span class='string'>&quot;nana&quot;</span>));</pre>
</div><h4 id='method.find' class='method'><code>fn <a href='#method.find' class='fnname'>find</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns the byte index of the first character of this string slice that
matches the pattern.</p>
<p>Returns <a href="option/enum.Option.html#variant.None"><code>None</code></a> if the pattern doesn&#39;t match.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines if
a character matches.</p>
<h1 id='examples-48' class='section-header'><a href='#examples-48'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>find</span>(<span class='string'>&#39;L&#39;</span>), <span class='prelude-val'>Some</span>(<span class='number'>0</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>find</span>(<span class='string'>&#39;é&#39;</span>), <span class='prelude-val'>Some</span>(<span class='number'>14</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>find</span>(<span class='string'>&quot;Léopard&quot;</span>), <span class='prelude-val'>Some</span>(<span class='number'>13</span>));</pre>
<p>More complex patterns with closures:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>find</span>(<span class='ident'>char</span>::<span class='ident'>is_whitespace</span>), <span class='prelude-val'>Some</span>(<span class='number'>5</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>find</span>(<span class='ident'>char</span>::<span class='ident'>is_lowercase</span>), <span class='prelude-val'>Some</span>(<span class='number'>1</span>));</pre>
<p>Not finding the pattern:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='kw'>let</span> <span class='ident'>x</span>: <span class='kw-2'>&amp;</span>[_] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='string'>&#39;1&#39;</span>, <span class='string'>&#39;2&#39;</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>find</span>(<span class='ident'>x</span>), <span class='prelude-val'>None</span>);</pre>
</div><h4 id='method.rfind' class='method'><code>fn <a href='#method.rfind' class='fnname'>rfind</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns the byte index of the last character of this string slice that
matches the pattern.</p>
<p>Returns <a href="option/enum.Option.html#variant.None"><code>None</code></a> if the pattern doesn&#39;t match.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines if
a character matches.</p>
<h1 id='examples-49' class='section-header'><a href='#examples-49'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>rfind</span>(<span class='string'>&#39;L&#39;</span>), <span class='prelude-val'>Some</span>(<span class='number'>13</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>rfind</span>(<span class='string'>&#39;é&#39;</span>), <span class='prelude-val'>Some</span>(<span class='number'>14</span>));</pre>
<p>More complex patterns with closures:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>rfind</span>(<span class='ident'>char</span>::<span class='ident'>is_whitespace</span>), <span class='prelude-val'>Some</span>(<span class='number'>12</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>rfind</span>(<span class='ident'>char</span>::<span class='ident'>is_lowercase</span>), <span class='prelude-val'>Some</span>(<span class='number'>20</span>));</pre>
<p>Not finding the pattern:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;Löwe 老虎 Léopard&quot;</span>;
<span class='kw'>let</span> <span class='ident'>x</span>: <span class='kw-2'>&amp;</span>[_] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='string'>&#39;1&#39;</span>, <span class='string'>&#39;2&#39;</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>rfind</span>(<span class='ident'>x</span>), <span class='prelude-val'>None</span>);</pre>
</div><h4 id='method.split' class='method'><code>fn <a href='#method.split' class='fnname'>split</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.Split.html' title='bitflags::__core::str::Split'>Split</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>An iterator over substrings of this string slice, separated by
characters matched by a pattern.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines the
split.</p>
<h1 id='iterator-behavior' class='section-header'><a href='#iterator-behavior'>Iterator behavior</a></h1>
<p>The returned iterator will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if the pattern
allows a reverse search and forward/reverse search yields the same
elements. This is true for, eg, <a href="primitive.char.html"><code>char</code></a> but not for <code>&amp;str</code>.</p>
<p>If the pattern allows a reverse search but its results might differ
from a forward search, the <a href="#method.rsplit"><code>rsplit()</code></a> method can be used.</p>
<h1 id='examples-50' class='section-header'><a href='#examples-50'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;Mary had a little lamb&quot;</span>.<span class='ident'>split</span>(<span class='string'>&#39; &#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;Mary&quot;</span>, <span class='string'>&quot;had&quot;</span>, <span class='string'>&quot;a&quot;</span>, <span class='string'>&quot;little&quot;</span>, <span class='string'>&quot;lamb&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;&quot;</span>.<span class='ident'>split</span>(<span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lionXXtigerXleopard&quot;</span>.<span class='ident'>split</span>(<span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;lion&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;tiger&quot;</span>, <span class='string'>&quot;leopard&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lion::tiger::leopard&quot;</span>.<span class='ident'>split</span>(<span class='string'>&quot;::&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;lion&quot;</span>, <span class='string'>&quot;tiger&quot;</span>, <span class='string'>&quot;leopard&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abc1def2ghi&quot;</span>.<span class='ident'>split</span>(<span class='ident'>char</span>::<span class='ident'>is_numeric</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;def&quot;</span>, <span class='string'>&quot;ghi&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lionXtigerXleopard&quot;</span>.<span class='ident'>split</span>(<span class='ident'>char</span>::<span class='ident'>is_uppercase</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;lion&quot;</span>, <span class='string'>&quot;tiger&quot;</span>, <span class='string'>&quot;leopard&quot;</span>]);</pre>
<p>A more complex pattern, using a closure:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abc1defXghi&quot;</span>.<span class='ident'>split</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;1&#39;</span> <span class='op'>||</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;def&quot;</span>, <span class='string'>&quot;ghi&quot;</span>]);</pre>
<p>If a string contains multiple contiguous separators, you will end up
with empty strings in the output:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>x</span> <span class='op'>=</span> <span class='string'>&quot;||||a||b|c&quot;</span>.<span class='ident'>to_string</span>();
<span class='kw'>let</span> <span class='ident'>d</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>x</span>.<span class='ident'>split</span>(<span class='string'>&#39;|&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>d</span>, <span class='kw-2'>&amp;</span>[<span class='string'>&quot;&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;a&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;b&quot;</span>, <span class='string'>&quot;c&quot;</span>]);</pre>
<p>This can lead to possibly surprising behavior when whitespace is used
as the separator. This code is correct:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>x</span> <span class='op'>=</span> <span class='string'>&quot; a b c&quot;</span>.<span class='ident'>to_string</span>();
<span class='kw'>let</span> <span class='ident'>d</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>x</span>.<span class='ident'>split</span>(<span class='string'>&#39; &#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>d</span>, <span class='kw-2'>&amp;</span>[<span class='string'>&quot;&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;a&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;b&quot;</span>, <span class='string'>&quot;c&quot;</span>]);</pre>
<p>It does <em>not</em> give you:</p>
<pre class='rust rust-example-rendered'>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>d</span>, <span class='kw-2'>&amp;</span>[<span class='string'>&quot;a&quot;</span>, <span class='string'>&quot;b&quot;</span>, <span class='string'>&quot;c&quot;</span>]);</pre>
<p>Use <a href="#method.split_whitespace"><code>split_whitespace()</code></a> for this behavior.</p>
</div><h4 id='method.rsplit' class='method'><code>fn <a href='#method.rsplit' class='fnname'>rsplit</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.RSplit.html' title='bitflags::__core::str::RSplit'>RSplit</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>An iterator over substrings of the given string slice, separated by
characters matched by a pattern and yielded in reverse order.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines the
split.</p>
<h1 id='iterator-behavior-1' class='section-header'><a href='#iterator-behavior-1'>Iterator behavior</a></h1>
<p>The returned iterator requires that the pattern supports a reverse
search, and it will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if a forward/reverse
search yields the same elements.</p>
<p>For iterating from the front, the <a href="#method.split"><code>split()</code></a> method can be used.</p>
<h1 id='examples-51' class='section-header'><a href='#examples-51'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;Mary had a little lamb&quot;</span>.<span class='ident'>rsplit</span>(<span class='string'>&#39; &#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;lamb&quot;</span>, <span class='string'>&quot;little&quot;</span>, <span class='string'>&quot;a&quot;</span>, <span class='string'>&quot;had&quot;</span>, <span class='string'>&quot;Mary&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;&quot;</span>.<span class='ident'>rsplit</span>(<span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lionXXtigerXleopard&quot;</span>.<span class='ident'>rsplit</span>(<span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;leopard&quot;</span>, <span class='string'>&quot;tiger&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;lion&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lion::tiger::leopard&quot;</span>.<span class='ident'>rsplit</span>(<span class='string'>&quot;::&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;leopard&quot;</span>, <span class='string'>&quot;tiger&quot;</span>, <span class='string'>&quot;lion&quot;</span>]);</pre>
<p>A more complex pattern, using a closure:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abc1defXghi&quot;</span>.<span class='ident'>rsplit</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;1&#39;</span> <span class='op'>||</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;ghi&quot;</span>, <span class='string'>&quot;def&quot;</span>, <span class='string'>&quot;abc&quot;</span>]);</pre>
</div><h4 id='method.split_terminator' class='method'><code>fn <a href='#method.split_terminator' class='fnname'>split_terminator</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.SplitTerminator.html' title='bitflags::__core::str::SplitTerminator'>SplitTerminator</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>An iterator over substrings of the given string slice, separated by
characters matched by a pattern.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines the
split.</p>
<p>Equivalent to <a href="#method.split"><code>split()</code></a>, except that the trailing substring
is skipped if empty.</p>
<p>This method can be used for string data that is <em>terminated</em>,
rather than <em>separated</em> by a pattern.</p>
<h1 id='iterator-behavior-2' class='section-header'><a href='#iterator-behavior-2'>Iterator behavior</a></h1>
<p>The returned iterator will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if the pattern
allows a reverse search and forward/reverse search yields the same
elements. This is true for, eg, <a href="primitive.char.html"><code>char</code></a> but not for <code>&amp;str</code>.</p>
<p>If the pattern allows a reverse search but its results might differ
from a forward search, the <a href="#method.rsplit_terminator"><code>rsplit_terminator()</code></a> method can be used.</p>
<h1 id='examples-52' class='section-header'><a href='#examples-52'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;A.B.&quot;</span>.<span class='ident'>split_terminator</span>(<span class='string'>&#39;.&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;A&quot;</span>, <span class='string'>&quot;B&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;A..B..&quot;</span>.<span class='ident'>split_terminator</span>(<span class='string'>&quot;.&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;A&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;B&quot;</span>, <span class='string'>&quot;&quot;</span>]);</pre>
</div><h4 id='method.rsplit_terminator' class='method'><code>fn <a href='#method.rsplit_terminator' class='fnname'>rsplit_terminator</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.RSplitTerminator.html' title='bitflags::__core::str::RSplitTerminator'>RSplitTerminator</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>An iterator over substrings of <code>self</code>, separated by characters
matched by a pattern and yielded in reverse order.</p>
<p>The pattern can be a simple <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that
determines the split.
Additional libraries might provide more complex patterns like
regular expressions.</p>
<p>Equivalent to <a href="#method.split"><code>split()</code></a>, except that the trailing substring is
skipped if empty.</p>
<p>This method can be used for string data that is <em>terminated</em>,
rather than <em>separated</em> by a pattern.</p>
<h1 id='iterator-behavior-3' class='section-header'><a href='#iterator-behavior-3'>Iterator behavior</a></h1>
<p>The returned iterator requires that the pattern supports a
reverse search, and it will be double ended if a forward/reverse
search yields the same elements.</p>
<p>For iterating from the front, the <a href="#method.split_terminator"><code>split_terminator()</code></a> method can be
used.</p>
<h1 id='examples-53' class='section-header'><a href='#examples-53'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;A.B.&quot;</span>.<span class='ident'>rsplit_terminator</span>(<span class='string'>&#39;.&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;B&quot;</span>, <span class='string'>&quot;A&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;A..B..&quot;</span>.<span class='ident'>rsplit_terminator</span>(<span class='string'>&quot;.&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;&quot;</span>, <span class='string'>&quot;B&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;A&quot;</span>]);</pre>
</div><h4 id='method.splitn' class='method'><code>fn <a href='#method.splitn' class='fnname'>splitn</a>&lt;'a, P&gt;(&amp;'a self, count: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.SplitN.html' title='bitflags::__core::str::SplitN'>SplitN</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>An iterator over substrings of the given string slice, separated by a
pattern, restricted to returning at most <code>count</code> items.</p>
<p>The last element returned, if any, will contain the remainder of the
string slice.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines the
split.</p>
<h1 id='iterator-behavior-4' class='section-header'><a href='#iterator-behavior-4'>Iterator behavior</a></h1>
<p>The returned iterator will not be double ended, because it is
not efficient to support.</p>
<p>If the pattern allows a reverse search, the <a href="#method.rsplitn"><code>rsplitn()</code></a> method can be
used.</p>
<h1 id='examples-54' class='section-header'><a href='#examples-54'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;Mary had a little lambda&quot;</span>.<span class='ident'>splitn</span>(<span class='number'>3</span>, <span class='string'>&#39; &#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;Mary&quot;</span>, <span class='string'>&quot;had&quot;</span>, <span class='string'>&quot;a little lambda&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lionXXtigerXleopard&quot;</span>.<span class='ident'>splitn</span>(<span class='number'>3</span>, <span class='string'>&quot;X&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;lion&quot;</span>, <span class='string'>&quot;&quot;</span>, <span class='string'>&quot;tigerXleopard&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abcXdef&quot;</span>.<span class='ident'>splitn</span>(<span class='number'>1</span>, <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;abcXdef&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;&quot;</span>.<span class='ident'>splitn</span>(<span class='number'>1</span>, <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;&quot;</span>]);</pre>
<p>A more complex pattern, using a closure:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abc1defXghi&quot;</span>.<span class='ident'>splitn</span>(<span class='number'>2</span>, <span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;1&#39;</span> <span class='op'>||</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;defXghi&quot;</span>]);</pre>
</div><h4 id='method.rsplitn' class='method'><code>fn <a href='#method.rsplitn' class='fnname'>rsplitn</a>&lt;'a, P&gt;(&amp;'a self, count: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.RSplitN.html' title='bitflags::__core::str::RSplitN'>RSplitN</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>An iterator over substrings of this string slice, separated by a
pattern, starting from the end of the string, restricted to returning
at most <code>count</code> items.</p>
<p>The last element returned, if any, will contain the remainder of the
string slice.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that
determines the split.</p>
<h1 id='iterator-behavior-5' class='section-header'><a href='#iterator-behavior-5'>Iterator behavior</a></h1>
<p>The returned iterator will not be double ended, because it is not
efficient to support.</p>
<p>For splitting from the front, the <a href="#method.splitn"><code>splitn()</code></a> method can be used.</p>
<h1 id='examples-55' class='section-header'><a href='#examples-55'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;Mary had a little lamb&quot;</span>.<span class='ident'>rsplitn</span>(<span class='number'>3</span>, <span class='string'>&#39; &#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;lamb&quot;</span>, <span class='string'>&quot;little&quot;</span>, <span class='string'>&quot;Mary had a&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lionXXtigerXleopard&quot;</span>.<span class='ident'>rsplitn</span>(<span class='number'>3</span>, <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;leopard&quot;</span>, <span class='string'>&quot;tiger&quot;</span>, <span class='string'>&quot;lionX&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;lion::tiger::leopard&quot;</span>.<span class='ident'>rsplitn</span>(<span class='number'>2</span>, <span class='string'>&quot;::&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;leopard&quot;</span>, <span class='string'>&quot;lion::tiger&quot;</span>]);</pre>
<p>A more complex pattern, using a closure:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abc1defXghi&quot;</span>.<span class='ident'>rsplitn</span>(<span class='number'>2</span>, <span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;1&#39;</span> <span class='op'>||</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;X&#39;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;ghi&quot;</span>, <span class='string'>&quot;abc1def&quot;</span>]);</pre>
</div><h4 id='method.matches' class='method'><code>fn <a href='#method.matches' class='fnname'>matches</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.Matches.html' title='bitflags::__core::str::Matches'>Matches</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code><span class="since">1.2.0</span></h4>
<div class='docblock'><p>An iterator over the matches of a pattern within the given string
slice.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that
determines if a character matches.</p>
<h1 id='iterator-behavior-6' class='section-header'><a href='#iterator-behavior-6'>Iterator behavior</a></h1>
<p>The returned iterator will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if the pattern
allows a reverse search and forward/reverse search yields the same
elements. This is true for, eg, <a href="primitive.char.html"><code>char</code></a> but not for <code>&amp;str</code>.</p>
<p>If the pattern allows a reverse search but its results might differ
from a forward search, the <a href="#method.rmatches"><code>rmatches()</code></a> method can be used.</p>
<h1 id='examples-56' class='section-header'><a href='#examples-56'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abcXXXabcYYYabc&quot;</span>.<span class='ident'>matches</span>(<span class='string'>&quot;abc&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;abc&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;1abc2abc3&quot;</span>.<span class='ident'>matches</span>(<span class='ident'>char</span>::<span class='ident'>is_numeric</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;1&quot;</span>, <span class='string'>&quot;2&quot;</span>, <span class='string'>&quot;3&quot;</span>]);</pre>
</div><h4 id='method.rmatches' class='method'><code>fn <a href='#method.rmatches' class='fnname'>rmatches</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.RMatches.html' title='bitflags::__core::str::RMatches'>RMatches</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code><span class="since">1.2.0</span></h4>
<div class='docblock'><p>An iterator over the matches of a pattern within this string slice,
yielded in reverse order.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines if
a character matches.</p>
<h1 id='iterator-behavior-7' class='section-header'><a href='#iterator-behavior-7'>Iterator behavior</a></h1>
<p>The returned iterator requires that the pattern supports a reverse
search, and it will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if a forward/reverse
search yields the same elements.</p>
<p>For iterating from the front, the <a href="#method.matches"><code>matches()</code></a> method can be used.</p>
<h1 id='examples-57' class='section-header'><a href='#examples-57'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abcXXXabcYYYabc&quot;</span>.<span class='ident'>rmatches</span>(<span class='string'>&quot;abc&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;abc&quot;</span>, <span class='string'>&quot;abc&quot;</span>]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;1abc2abc3&quot;</span>.<span class='ident'>rmatches</span>(<span class='ident'>char</span>::<span class='ident'>is_numeric</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [<span class='string'>&quot;3&quot;</span>, <span class='string'>&quot;2&quot;</span>, <span class='string'>&quot;1&quot;</span>]);</pre>
</div><h4 id='method.match_indices' class='method'><code>fn <a href='#method.match_indices' class='fnname'>match_indices</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.MatchIndices.html' title='bitflags::__core::str::MatchIndices'>MatchIndices</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code><span class="since">1.5.0</span></h4>
<div class='docblock'><p>An iterator over the disjoint matches of a pattern within this string
slice as well as the index that the match starts at.</p>
<p>For matches of <code>pat</code> within <code>self</code> that overlap, only the indices
corresponding to the first match are returned.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines
if a character matches.</p>
<h1 id='iterator-behavior-8' class='section-header'><a href='#iterator-behavior-8'>Iterator behavior</a></h1>
<p>The returned iterator will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if the pattern
allows a reverse search and forward/reverse search yields the same
elements. This is true for, eg, <a href="primitive.char.html"><code>char</code></a> but not for <code>&amp;str</code>.</p>
<p>If the pattern allows a reverse search but its results might differ
from a forward search, the <a href="#method.rmatch_indices"><code>rmatch_indices()</code></a> method can be used.</p>
<h1 id='examples-58' class='section-header'><a href='#examples-58'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abcXXXabcYYYabc&quot;</span>.<span class='ident'>match_indices</span>(<span class='string'>&quot;abc&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [(<span class='number'>0</span>, <span class='string'>&quot;abc&quot;</span>), (<span class='number'>6</span>, <span class='string'>&quot;abc&quot;</span>), (<span class='number'>12</span>, <span class='string'>&quot;abc&quot;</span>)]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;1abcabc2&quot;</span>.<span class='ident'>match_indices</span>(<span class='string'>&quot;abc&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [(<span class='number'>1</span>, <span class='string'>&quot;abc&quot;</span>), (<span class='number'>4</span>, <span class='string'>&quot;abc&quot;</span>)]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;ababa&quot;</span>.<span class='ident'>match_indices</span>(<span class='string'>&quot;aba&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [(<span class='number'>0</span>, <span class='string'>&quot;aba&quot;</span>)]); <span class='comment'>// only the first `aba`</span></pre>
</div><h4 id='method.rmatch_indices' class='method'><code>fn <a href='#method.rmatch_indices' class='fnname'>rmatch_indices</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; <a class='struct' href='../../../bitflags/__core/str/struct.RMatchIndices.html' title='bitflags::__core::str::RMatchIndices'>RMatchIndices</a>&lt;'a, P&gt; <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code><span class="since">1.5.0</span></h4>
<div class='docblock'><p>An iterator over the disjoint matches of a pattern within <code>self</code>,
yielded in reverse order along with the index of the match.</p>
<p>For matches of <code>pat</code> within <code>self</code> that overlap, only the indices
corresponding to the last match are returned.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines if a
character matches.</p>
<h1 id='iterator-behavior-9' class='section-header'><a href='#iterator-behavior-9'>Iterator behavior</a></h1>
<p>The returned iterator requires that the pattern supports a reverse
search, and it will be a <a href="iter/trait.DoubleEndedIterator.html"><code>DoubleEndedIterator</code></a> if a forward/reverse
search yields the same elements.</p>
<p>For iterating from the front, the <a href="#method.match_indices"><code>match_indices()</code></a> method can be used.</p>
<h1 id='examples-59' class='section-header'><a href='#examples-59'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;abcXXXabcYYYabc&quot;</span>.<span class='ident'>rmatch_indices</span>(<span class='string'>&quot;abc&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [(<span class='number'>12</span>, <span class='string'>&quot;abc&quot;</span>), (<span class='number'>6</span>, <span class='string'>&quot;abc&quot;</span>), (<span class='number'>0</span>, <span class='string'>&quot;abc&quot;</span>)]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;1abcabc2&quot;</span>.<span class='ident'>rmatch_indices</span>(<span class='string'>&quot;abc&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [(<span class='number'>4</span>, <span class='string'>&quot;abc&quot;</span>), (<span class='number'>1</span>, <span class='string'>&quot;abc&quot;</span>)]);
<span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;</span> <span class='op'>=</span> <span class='string'>&quot;ababa&quot;</span>.<span class='ident'>rmatch_indices</span>(<span class='string'>&quot;aba&quot;</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, [(<span class='number'>2</span>, <span class='string'>&quot;aba&quot;</span>)]); <span class='comment'>// only the last `aba`</span></pre>
</div><h4 id='method.trim' class='method'><code>fn <a href='#method.trim' class='fnname'>trim</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='docblock'><p>Returns a string slice with leading and trailing whitespace removed.</p>
<p>&#39;Whitespace&#39; is defined according to the terms of the Unicode Derived
Core Property <code>White_Space</code>.</p>
<h1 id='examples-60' class='section-header'><a href='#examples-60'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot; Hello\tworld\t&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;Hello\tworld&quot;</span>, <span class='ident'>s</span>.<span class='ident'>trim</span>());</pre>
</div><h4 id='method.trim_left' class='method'><code>fn <a href='#method.trim_left' class='fnname'>trim_left</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='docblock'><p>Returns a string slice with leading whitespace removed.</p>
<p>&#39;Whitespace&#39; is defined according to the terms of the Unicode Derived
Core Property <code>White_Space</code>.</p>
<h1 id='text-directionality' class='section-header'><a href='#text-directionality'>Text directionality</a></h1>
<p>A string is a sequence of bytes. &#39;Left&#39; in this context means the first
position of that byte string; for a language like Arabic or Hebrew
which are &#39;right to left&#39; rather than &#39;left to right&#39;, this will be
the <em>right</em> side, not the left.</p>
<h1 id='examples-61' class='section-header'><a href='#examples-61'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot; Hello\tworld\t&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;Hello\tworld\t&quot;</span>, <span class='ident'>s</span>.<span class='ident'>trim_left</span>());</pre>
<p>Directionality:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot; English&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;E&#39;</span>) <span class='op'>==</span> <span class='ident'>s</span>.<span class='ident'>trim_left</span>().<span class='ident'>chars</span>().<span class='ident'>next</span>());
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot; עברית&quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;ע&#39;</span>) <span class='op'>==</span> <span class='ident'>s</span>.<span class='ident'>trim_left</span>().<span class='ident'>chars</span>().<span class='ident'>next</span>());</pre>
</div><h4 id='method.trim_right' class='method'><code>fn <a href='#method.trim_right' class='fnname'>trim_right</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='docblock'><p>Returns a string slice with trailing whitespace removed.</p>
<p>&#39;Whitespace&#39; is defined according to the terms of the Unicode Derived
Core Property <code>White_Space</code>.</p>
<h1 id='text-directionality-1' class='section-header'><a href='#text-directionality-1'>Text directionality</a></h1>
<p>A string is a sequence of bytes. &#39;Right&#39; in this context means the last
position of that byte string; for a language like Arabic or Hebrew
which are &#39;right to left&#39; rather than &#39;left to right&#39;, this will be
the <em>left</em> side, not the right.</p>
<h1 id='examples-62' class='section-header'><a href='#examples-62'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot; Hello\tworld\t&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot; Hello\tworld&quot;</span>, <span class='ident'>s</span>.<span class='ident'>trim_right</span>());</pre>
<p>Directionality:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;English &quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;h&#39;</span>) <span class='op'>==</span> <span class='ident'>s</span>.<span class='ident'>trim_right</span>().<span class='ident'>chars</span>().<span class='ident'>rev</span>().<span class='ident'>next</span>());
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;עברית &quot;</span>;
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='string'>&#39;ת&#39;</span>) <span class='op'>==</span> <span class='ident'>s</span>.<span class='ident'>trim_right</span>().<span class='ident'>chars</span>().<span class='ident'>rev</span>().<span class='ident'>next</span>());</pre>
</div><h4 id='method.trim_matches' class='method'><code>fn <a href='#method.trim_matches' class='fnname'>trim_matches</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.DoubleEndedSearcher.html' title='bitflags::__core::str::pattern::DoubleEndedSearcher'>DoubleEndedSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns a string slice with all prefixes and suffixes that match a
pattern repeatedly removed.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines
if a character matches.</p>
<h1 id='examples-63' class='section-header'><a href='#examples-63'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;11foo1bar11&quot;</span>.<span class='ident'>trim_matches</span>(<span class='string'>&#39;1&#39;</span>), <span class='string'>&quot;foo1bar&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;123foo1bar123&quot;</span>.<span class='ident'>trim_matches</span>(<span class='ident'>char</span>::<span class='ident'>is_numeric</span>), <span class='string'>&quot;foo1bar&quot;</span>);
<span class='kw'>let</span> <span class='ident'>x</span>: <span class='kw-2'>&amp;</span>[_] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='string'>&#39;1&#39;</span>, <span class='string'>&#39;2&#39;</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;12foo1bar12&quot;</span>.<span class='ident'>trim_matches</span>(<span class='ident'>x</span>), <span class='string'>&quot;foo1bar&quot;</span>);</pre>
<p>A more complex pattern, using a closure:</p>
<pre class='rust rust-example-rendered'>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;1foo1barXX&quot;</span>.<span class='ident'>trim_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;1&#39;</span> <span class='op'>||</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;X&#39;</span>), <span class='string'>&quot;foo1bar&quot;</span>);</pre>
</div><h4 id='method.trim_left_matches' class='method'><code>fn <a href='#method.trim_left_matches' class='fnname'>trim_left_matches</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns a string slice with all prefixes that match a pattern
repeatedly removed.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that determines if
a character matches.</p>
<h1 id='text-directionality-2' class='section-header'><a href='#text-directionality-2'>Text directionality</a></h1>
<p>A string is a sequence of bytes. &#39;Left&#39; in this context means the first
position of that byte string; for a language like Arabic or Hebrew
which are &#39;right to left&#39; rather than &#39;left to right&#39;, this will be
the <em>right</em> side, not the left.</p>
<h1 id='examples-64' class='section-header'><a href='#examples-64'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;11foo1bar11&quot;</span>.<span class='ident'>trim_left_matches</span>(<span class='string'>&#39;1&#39;</span>), <span class='string'>&quot;foo1bar11&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;123foo1bar123&quot;</span>.<span class='ident'>trim_left_matches</span>(<span class='ident'>char</span>::<span class='ident'>is_numeric</span>), <span class='string'>&quot;foo1bar123&quot;</span>);
<span class='kw'>let</span> <span class='ident'>x</span>: <span class='kw-2'>&amp;</span>[_] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='string'>&#39;1&#39;</span>, <span class='string'>&#39;2&#39;</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;12foo1bar12&quot;</span>.<span class='ident'>trim_left_matches</span>(<span class='ident'>x</span>), <span class='string'>&quot;foo1bar12&quot;</span>);</pre>
</div><h4 id='method.trim_right_matches' class='method'><code>fn <a href='#method.trim_right_matches' class='fnname'>trim_right_matches</a>&lt;'a, P&gt;(&amp;'a self, pat: P) -&gt; &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;, P::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Returns a string slice with all suffixes that match a pattern
repeatedly removed.</p>
<p>The pattern can be a <code>&amp;str</code>, <a href="primitive.char.html"><code>char</code></a>, or a closure that
determines if a character matches.</p>
<h1 id='text-directionality-3' class='section-header'><a href='#text-directionality-3'>Text directionality</a></h1>
<p>A string is a sequence of bytes. &#39;Right&#39; in this context means the last
position of that byte string; for a language like Arabic or Hebrew
which are &#39;right to left&#39; rather than &#39;left to right&#39;, this will be
the <em>left</em> side, not the right.</p>
<h1 id='examples-65' class='section-header'><a href='#examples-65'>Examples</a></h1>
<p>Simple patterns:</p>
<pre class='rust rust-example-rendered'>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;11foo1bar11&quot;</span>.<span class='ident'>trim_right_matches</span>(<span class='string'>&#39;1&#39;</span>), <span class='string'>&quot;11foo1bar&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;123foo1bar123&quot;</span>.<span class='ident'>trim_right_matches</span>(<span class='ident'>char</span>::<span class='ident'>is_numeric</span>), <span class='string'>&quot;123foo1bar&quot;</span>);
<span class='kw'>let</span> <span class='ident'>x</span>: <span class='kw-2'>&amp;</span>[_] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[<span class='string'>&#39;1&#39;</span>, <span class='string'>&#39;2&#39;</span>];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;12foo1bar12&quot;</span>.<span class='ident'>trim_right_matches</span>(<span class='ident'>x</span>), <span class='string'>&quot;12foo1bar&quot;</span>);</pre>
<p>A more complex pattern, using a closure:</p>
<pre class='rust rust-example-rendered'>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;1fooX&quot;</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;1&#39;</span> <span class='op'>||</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;X&#39;</span>), <span class='string'>&quot;fooX&quot;</span>);</pre>
</div><h4 id='method.parse' class='method'><code>fn <a href='#method.parse' class='fnname'>parse</a>&lt;F&gt;(&amp;self) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;F, F::<a class='trait' href='../../../bitflags/__core/str/trait.FromStr.html' title='bitflags::__core::str::FromStr'>Err</a>&gt; <span class='where'>where F: <a class='trait' href='../../../bitflags/__core/str/trait.FromStr.html' title='bitflags::__core::str::FromStr'>FromStr</a></span></code></h4>
<div class='docblock'><p>Parses this string slice into another type.</p>
<p>Because <code>parse()</code> is so general, it can cause problems with type
inference. As such, <code>parse()</code> is one of the few times you&#39;ll see
the syntax affectionately known as the &#39;turbofish&#39;: <code>::&lt;&gt;</code>. This
helps the inference algorithm understand specifically which type
you&#39;re trying to parse into.</p>
<p><code>parse()</code> can parse any type that implements the <a href="str/trait.FromStr.html"><code>FromStr</code></a> trait.</p>
<h1 id='errors-1' class='section-header'><a href='#errors-1'>Errors</a></h1>
<p>Will return <a href="str/trait.FromStr.html#associatedtype.Err"><code>Err</code></a> if it&#39;s not possible to parse this string slice into
the desired type.</p>
<h1 id='example' class='section-header'><a href='#example'>Example</a></h1>
<p>Basic usage</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>four</span>: <span class='ident'>u32</span> <span class='op'>=</span> <span class='string'>&quot;4&quot;</span>.<span class='ident'>parse</span>().<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>4</span>, <span class='ident'>four</span>);</pre>
<p>Using the &#39;turbofish&#39; instead of annotating <code>four</code>:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>four</span> <span class='op'>=</span> <span class='string'>&quot;4&quot;</span>.<span class='ident'>parse</span>::<span class='op'>&lt;</span><span class='ident'>u32</span><span class='op'>&gt;</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Ok</span>(<span class='number'>4</span>), <span class='ident'>four</span>);</pre>
<p>Failing to parse:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>nope</span> <span class='op'>=</span> <span class='string'>&quot;j&quot;</span>.<span class='ident'>parse</span>::<span class='op'>&lt;</span><span class='ident'>u32</span><span class='op'>&gt;</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>nope</span>.<span class='ident'>is_err</span>());</pre>
</div><h4 id='method.replace' class='method'><code>fn <a href='#method.replace' class='fnname'>replace</a>&lt;'a, P&gt;(&amp;'a self, from: P, to: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a> <span class='where'>where P: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt;</span></code></h4>
<div class='docblock'><p>Replaces all matches of a pattern with another string.</p>
<p><code>replace</code> creates a new <a href="string/struct.String.html"><code>String</code></a>, and copies the data from this string slice into it.
While doing so, it attempts to find matches of a pattern. If it finds any, it
replaces them with the replacement string slice.</p>
<h1 id='examples-66' class='section-header'><a href='#examples-66'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;this is old&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;this is new&quot;</span>, <span class='ident'>s</span>.<span class='ident'>replace</span>(<span class='string'>&quot;old&quot;</span>, <span class='string'>&quot;new&quot;</span>));</pre>
<p>When the pattern doesn&#39;t match:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;this is old&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='ident'>s</span>.<span class='ident'>replace</span>(<span class='string'>&quot;cookie monster&quot;</span>, <span class='string'>&quot;little lamb&quot;</span>));</pre>
</div><h4 id='method.to_lowercase' class='method'><code>fn <a href='#method.to_lowercase' class='fnname'>to_lowercase</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h4>
<div class='docblock'><p>Returns the lowercase equivalent of this string slice, as a new <a href="string/struct.String.html"><code>String</code></a>.</p>
<p>&#39;Lowercase&#39; is defined according to the terms of the Unicode Derived Core Property
<code>Lowercase</code>.</p>
<h1 id='examples-67' class='section-header'><a href='#examples-67'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;HELLO&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;hello&quot;</span>, <span class='ident'>s</span>.<span class='ident'>to_lowercase</span>());</pre>
<p>A tricky example, with sigma:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>sigma</span> <span class='op'>=</span> <span class='string'>&quot;Σ&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;σ&quot;</span>, <span class='ident'>sigma</span>.<span class='ident'>to_lowercase</span>());
<span class='comment'>// but at the end of a word, it&#39;s ς, not σ:</span>
<span class='kw'>let</span> <span class='ident'>odysseus</span> <span class='op'>=</span> <span class='string'>&quot;ὈΔΥΣΣΕΎΣ&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;ὀδυσσεύς&quot;</span>, <span class='ident'>odysseus</span>.<span class='ident'>to_lowercase</span>());</pre>
<p>Languages without case are not changed:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>new_year</span> <span class='op'>=</span> <span class='string'>&quot;农历新年&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>new_year</span>, <span class='ident'>new_year</span>.<span class='ident'>to_lowercase</span>());</pre>
</div><h4 id='method.to_uppercase' class='method'><code>fn <a href='#method.to_uppercase' class='fnname'>to_uppercase</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h4>
<div class='docblock'><p>Returns the uppercase equivalent of this string slice, as a new <a href="string/struct.String.html"><code>String</code></a>.</p>
<p>&#39;Uppercase&#39; is defined according to the terms of the Unicode Derived Core Property
<code>Uppercase</code>.</p>
<h1 id='examples-68' class='section-header'><a href='#examples-68'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='string'>&quot;hello&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;HELLO&quot;</span>, <span class='ident'>s</span>.<span class='ident'>to_uppercase</span>());</pre>
<p>Scripts without case are not changed:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>new_year</span> <span class='op'>=</span> <span class='string'>&quot;农历新年&quot;</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>new_year</span>, <span class='ident'>new_year</span>.<span class='ident'>to_uppercase</span>());</pre>
</div><h4 id='method.escape_default' class='method'><code>fn <a href='#method.escape_default' class='fnname'>escape_default</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>str_escape</code>)<p>: return type may change to be an iterator</p>
</em></div><div class='docblock'><p>Escapes each char in <code>s</code> with <code>char::escape_default</code>.</p>
</div><h4 id='method.escape_unicode' class='method'><code>fn <a href='#method.escape_unicode' class='fnname'>escape_unicode</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>str_escape</code>)<p>: return type may change to be an iterator</p>
</em></div><div class='docblock'><p>Escapes each char in <code>s</code> with <code>char::escape_unicode</code>.</p>
</div><h4 id='method.into_string' class='method'><code>fn <a href='#method.into_string' class='fnname'>into_string</a>(self: <a class='struct' href='../../../bitflags/__core/boxed/struct.Box.html' title='bitflags::__core::boxed::Box'>Box</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.4.0</span></h4>
<div class='docblock'><p>Converts a <code>Box&lt;str&gt;</code> into a <a href="string/struct.String.html"><code>String</code></a> without copying or allocating.</p>
<h1 id='examples-69' class='section-header'><a href='#examples-69'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>string</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;birthday gift&quot;</span>);
<span class='kw'>let</span> <span class='ident'>boxed_str</span> <span class='op'>=</span> <span class='ident'>string</span>.<span class='ident'>clone</span>().<span class='ident'>into_boxed_str</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>boxed_str</span>.<span class='ident'>into_string</span>(), <span class='ident'>string</span>);</pre>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/convert/trait.AsRef.html' title='bitflags::__core::convert::AsRef'>AsRef</a>&lt;<a class='struct' href='../../../bitflags/__core/ffi/struct.OsStr.html' title='bitflags::__core::ffi::OsStr'>OsStr</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.as_ref' class='method'><code>fn <a href='../../../bitflags/__core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&amp;self) -&gt; &amp;<a class='struct' href='../../../bitflags/__core/ffi/struct.OsStr.html' title='bitflags::__core::ffi::OsStr'>OsStr</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/convert/trait.AsRef.html' title='bitflags::__core::convert::AsRef'>AsRef</a>&lt;<a class='struct' href='../../../bitflags/__core/path/struct.Path.html' title='bitflags::__core::path::Path'>Path</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.as_ref-1' class='method'><code>fn <a href='../../../bitflags/__core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&amp;self) -&gt; &amp;<a class='struct' href='../../../bitflags/__core/path/struct.Path.html' title='bitflags::__core::path::Path'>Path</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/borrow/trait.Borrow.html' title='bitflags::__core::borrow::Borrow'>Borrow</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.borrow' class='method'><code>fn <a href='../../../bitflags/__core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/clone/trait.Clone.html' title='bitflags::__core::clone::Clone'>Clone</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='../../../bitflags/__core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<h4 id='method.clone_from' class='method'><code>fn <a href='../../../bitflags/__core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>)</code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/iter/trait.FromIterator.html' title='bitflags::__core::iter::FromIterator'>FromIterator</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.from_iter' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.FromIterator.html#tymethod.from_iter' class='fnname'>from_iter</a>&lt;I&gt;(iter: I) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a> <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl&lt;'a&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.FromIterator.html' title='bitflags::__core::iter::FromIterator'>FromIterator</a>&lt;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.from_iter-1' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.FromIterator.html#tymethod.from_iter' class='fnname'>from_iter</a>&lt;I&gt;(iter: I) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a> <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/iter/trait.FromIterator.html' title='bitflags::__core::iter::FromIterator'>FromIterator</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.4.0</span></h3><div class='impl-items'><h4 id='method.from_iter-2' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.FromIterator.html#tymethod.from_iter' class='fnname'>from_iter</a>&lt;I&gt;(iter: I) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a> <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/iter/trait.Extend.html' title='bitflags::__core::iter::Extend'>Extend</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.extend' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.Extend.html#tymethod.extend' class='fnname'>extend</a>&lt;I&gt;(&amp;mut self, iter: I) <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl&lt;'a&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.Extend.html' title='bitflags::__core::iter::Extend'>Extend</a>&lt;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h3><div class='impl-items'><h4 id='method.extend-1' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.Extend.html#tymethod.extend' class='fnname'>extend</a>&lt;I&gt;(&amp;mut self, iter: I) <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl&lt;'a&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.Extend.html' title='bitflags::__core::iter::Extend'>Extend</a>&lt;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.extend-2' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.Extend.html#tymethod.extend' class='fnname'>extend</a>&lt;I&gt;(&amp;mut self, iter: I) <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/iter/trait.Extend.html' title='bitflags::__core::iter::Extend'>Extend</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.4.0</span></h3><div class='impl-items'><h4 id='method.extend-3' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.Extend.html#tymethod.extend' class='fnname'>extend</a>&lt;I&gt;(&amp;mut self, iter: I) <span class='where'>where I: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl&lt;'a, 'b&gt; <a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Pattern</a>&lt;'a&gt; for &amp;'b <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='docblock'><p>A convenience impl that delegates to the impl for <code>&amp;str</code></p>
</div><div class='impl-items'><h4 id='associatedtype.Searcher' class='type'><code>type <a href='../../../bitflags/__core/str/pattern/trait.Pattern.html#associatedtype.Searcher' class='type'>Searcher</a> = &amp;'b <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>pattern</code>)<p>: API not fully fleshed out and ready to be stabilized</p>
</em></div><h4 id='method.into_searcher' class='method'><code>fn <a href='../../../bitflags/__core/str/pattern/trait.Pattern.html#tymethod.into_searcher' class='fnname'>into_searcher</a>(self, haystack: &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; &amp;'b <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>pattern</code>)<p>: API not fully fleshed out and ready to be stabilized</p>
</em></div><h4 id='method.is_contained_in' class='method'><code>fn <a href='../../../bitflags/__core/str/pattern/trait.Pattern.html#method.is_contained_in' class='fnname'>is_contained_in</a>(self, haystack: &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>pattern</code>)<p>: API not fully fleshed out and ready to be stabilized</p>
</em></div><h4 id='method.is_prefix_of' class='method'><code>fn <a href='../../../bitflags/__core/str/pattern/trait.Pattern.html#method.is_prefix_of' class='fnname'>is_prefix_of</a>(self, haystack: &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>pattern</code>)<p>: API not fully fleshed out and ready to be stabilized</p>
</em></div><h4 id='method.is_suffix_of' class='method'><code>fn <a href='../../../bitflags/__core/str/pattern/trait.Pattern.html#method.is_suffix_of' class='fnname'>is_suffix_of</a>(self, haystack: &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a> <span class='where'>where Self::<a class='trait' href='../../../bitflags/__core/str/pattern/trait.Pattern.html' title='bitflags::__core::str::pattern::Pattern'>Searcher</a>: <a class='trait' href='../../../bitflags/__core/str/pattern/trait.ReverseSearcher.html' title='bitflags::__core::str::pattern::ReverseSearcher'>ReverseSearcher</a>&lt;'a&gt;</span></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.ne' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
</div><h3 class='impl'><code>impl&lt;'a, 'b&gt; <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.eq-1' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.ne-1' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
</div><h3 class='impl'><code>impl&lt;'a, 'b&gt; <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a>&lt;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.eq-2' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.ne-2' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
</div><h3 class='impl'><code>impl&lt;'a, 'b&gt; <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a>&lt;<a class='enum' href='../../../bitflags/__core/borrow/enum.Cow.html' title='bitflags::__core::borrow::Cow'>Cow</a>&lt;'a, <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.eq-3' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class='enum' href='../../../bitflags/__core/borrow/enum.Cow.html' title='bitflags::__core::borrow::Cow'>Cow</a>&lt;'a, <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.ne-3' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;<a class='enum' href='../../../bitflags/__core/borrow/enum.Cow.html' title='bitflags::__core::borrow::Cow'>Cow</a>&lt;'a, <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt;) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/default/trait.Default.html' title='bitflags::__core::default::Default'>Default</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.default' class='method'><code>fn <a href='../../../bitflags/__core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/fmt/trait.Display.html' title='bitflags::__core::fmt::Display'>Display</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class='struct' href='../../../bitflags/__core/fmt/struct.Formatter.html' title='bitflags::__core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>&gt;</code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/fmt/trait.Debug.html' title='bitflags::__core::fmt::Debug'>Debug</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.fmt-1' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class='struct' href='../../../bitflags/__core/fmt/struct.Formatter.html' title='bitflags::__core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>&gt;</code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.hash' class='method'><code>fn <a href='../../../bitflags/__core/hash/trait.Hash.html#tymethod.hash' class='fnname'>hash</a>&lt;H&gt;(&amp;self, hasher: &amp;mut H) <span class='where'>where H: <a class='trait' href='../../../bitflags/__core/hash/trait.Hasher.html' title='bitflags::__core::hash::Hasher'>Hasher</a></span></code></h4>
<h4 id='method.hash_slice' class='method'><code>fn <a href='../../../bitflags/__core/hash/trait.Hash.html#method.hash_slice' class='fnname'>hash_slice</a>&lt;H&gt;(data: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;[Self]</a>, state: &amp;mut H) <span class='where'>where H: <a class='trait' href='../../../bitflags/__core/hash/trait.Hasher.html' title='bitflags::__core::hash::Hasher'>Hasher</a></span></code><span class="since">1.3.0</span></h4>
</div><h3 class='impl'><code>impl&lt;'a&gt; <a class='trait' href='../../../bitflags/__core/ops/trait.Add.html' title='bitflags::__core::ops::Add'>Add</a>&lt;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Add.html#associatedtype.Output' class='type'>Output</a> = <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
<h4 id='method.add' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Add.html#tymethod.add' class='fnname'>add</a>(self, other: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.Range.html' title='bitflags::__core::ops::Range'>Range</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-1' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<h4 id='method.index' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.Range.html' title='bitflags::__core::ops::Range'>Range</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeTo.html' title='bitflags::__core::ops::RangeTo'>RangeTo</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-2' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<h4 id='method.index-1' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeTo.html' title='bitflags::__core::ops::RangeTo'>RangeTo</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeFrom.html' title='bitflags::__core::ops::RangeFrom'>RangeFrom</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-3' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<h4 id='method.index-2' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeFrom.html' title='bitflags::__core::ops::RangeFrom'>RangeFrom</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeFull.html' title='bitflags::__core::ops::RangeFull'>RangeFull</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-4' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<h4 id='method.index-3' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, _index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeFull.html' title='bitflags::__core::ops::RangeFull'>RangeFull</a>) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;<a class='enum' href='../../../bitflags/__core/ops/enum.RangeInclusive.html' title='bitflags::__core::ops::RangeInclusive'>RangeInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-5' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>inclusive_range</code>)<p>: recently added, follows RFC</p>
</em></div><h4 id='method.index-4' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, index: <a class='enum' href='../../../bitflags/__core/ops/enum.RangeInclusive.html' title='bitflags::__core::ops::RangeInclusive'>RangeInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>inclusive_range</code>)<p>: recently added, follows RFC</p>
</em></div></div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeToInclusive.html' title='bitflags::__core::ops::RangeToInclusive'>RangeToInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-6' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>inclusive_range</code>)<p>: recently added, follows RFC</p>
</em></div><h4 id='method.index-5' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeToInclusive.html' title='bitflags::__core::ops::RangeToInclusive'>RangeToInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>inclusive_range</code>)<p>: recently added, follows RFC</p>
</em></div></div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.IndexMut.html' title='bitflags::__core::ops::IndexMut'>IndexMut</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.Range.html' title='bitflags::__core::ops::Range'>Range</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h3><div class='impl-items'><h4 id='method.index_mut' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.IndexMut.html#tymethod.index_mut' class='fnname'>index_mut</a>(&amp;mut self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.Range.html' title='bitflags::__core::ops::Range'>Range</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.IndexMut.html' title='bitflags::__core::ops::IndexMut'>IndexMut</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeTo.html' title='bitflags::__core::ops::RangeTo'>RangeTo</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h3><div class='impl-items'><h4 id='method.index_mut-1' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.IndexMut.html#tymethod.index_mut' class='fnname'>index_mut</a>(&amp;mut self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeTo.html' title='bitflags::__core::ops::RangeTo'>RangeTo</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.IndexMut.html' title='bitflags::__core::ops::IndexMut'>IndexMut</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeFrom.html' title='bitflags::__core::ops::RangeFrom'>RangeFrom</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h3><div class='impl-items'><h4 id='method.index_mut-2' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.IndexMut.html#tymethod.index_mut' class='fnname'>index_mut</a>(&amp;mut self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeFrom.html' title='bitflags::__core::ops::RangeFrom'>RangeFrom</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.IndexMut.html' title='bitflags::__core::ops::IndexMut'>IndexMut</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeFull.html' title='bitflags::__core::ops::RangeFull'>RangeFull</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h3><div class='impl-items'><h4 id='method.index_mut-3' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.IndexMut.html#tymethod.index_mut' class='fnname'>index_mut</a>(&amp;mut self, _index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeFull.html' title='bitflags::__core::ops::RangeFull'>RangeFull</a>) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.IndexMut.html' title='bitflags::__core::ops::IndexMut'>IndexMut</a>&lt;<a class='enum' href='../../../bitflags/__core/ops/enum.RangeInclusive.html' title='bitflags::__core::ops::RangeInclusive'>RangeInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.index_mut-4' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.IndexMut.html#tymethod.index_mut' class='fnname'>index_mut</a>(&amp;mut self, index: <a class='enum' href='../../../bitflags/__core/ops/enum.RangeInclusive.html' title='bitflags::__core::ops::RangeInclusive'>RangeInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>inclusive_range</code>)<p>: recently added, follows RFC</p>
</em></div></div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.IndexMut.html' title='bitflags::__core::ops::IndexMut'>IndexMut</a>&lt;<a class='struct' href='../../../bitflags/__core/ops/struct.RangeToInclusive.html' title='bitflags::__core::ops::RangeToInclusive'>RangeToInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.index_mut-5' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.IndexMut.html#tymethod.index_mut' class='fnname'>index_mut</a>(&amp;mut self, index: <a class='struct' href='../../../bitflags/__core/ops/struct.RangeToInclusive.html' title='bitflags::__core::ops::RangeToInclusive'>RangeToInclusive</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>&gt;) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>inclusive_range</code>)<p>: recently added, follows RFC</p>
</em></div></div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Deref.html' title='bitflags::__core::ops::Deref'>Deref</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Target' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Deref.html#associatedtype.Target' class='type'>Target</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
<h4 id='method.deref' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.DerefMut.html' title='bitflags::__core::ops::DerefMut'>DerefMut</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code><span class="since">1.2.0</span></h3><div class='impl-items'><h4 id='method.deref_mut' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.DerefMut.html#tymethod.deref_mut' class='fnname'>deref_mut</a>(&amp;mut self) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/str/trait.FromStr.html' title='bitflags::__core::str::FromStr'>FromStr</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='associatedtype.Err' class='type'><code>type <a href='../../../bitflags/__core/str/trait.FromStr.html#associatedtype.Err' class='type'>Err</a> = <a class='enum' href='../../../bitflags/__core/string/enum.ParseError.html' title='bitflags::__core::string::ParseError'>ParseError</a></code></h4>
<h4 id='method.from_str' class='method'><code>fn <a href='../../../bitflags/__core/str/trait.FromStr.html#tymethod.from_str' class='fnname'>from_str</a>(s: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>, <a class='enum' href='../../../bitflags/__core/string/enum.ParseError.html' title='bitflags::__core::string::ParseError'>ParseError</a>&gt;</code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/convert/trait.AsRef.html' title='bitflags::__core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.as_ref-2' class='method'><code>fn <a href='../../../bitflags/__core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/convert/trait.AsRef.html' title='bitflags::__core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.as_ref-3' class='method'><code>fn <a href='../../../bitflags/__core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a></code></h4>
</div><h3 class='impl'><code>impl&lt;'a&gt; <a class='trait' href='../../../bitflags/__core/convert/trait.From.html' title='bitflags::__core::convert::From'>From</a>&lt;&amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.from' class='method'><code>fn <a href='../../../bitflags/__core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(s: &amp;'a <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/convert/trait.Into.html' title='bitflags::__core::convert::Into'>Into</a>&lt;<a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>&gt;&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.into' class='method'><code>fn <a href='../../../bitflags/__core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; <a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>&gt;</code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/fmt/trait.Write.html' title='bitflags::__core::fmt::Write'>Write</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.write_str' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Write.html#tymethod.write_str' class='fnname'>write_str</a>(&amp;mut self, s: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.str.html'>str</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>&gt;</code></h4>
<h4 id='method.write_char' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Write.html#method.write_char' class='fnname'>write_char</a>(&amp;mut self, c: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.char.html'>char</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>&gt;</code></h4>
<h4 id='method.write_fmt' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Write.html#method.write_fmt' class='fnname'>write_fmt</a>(&amp;mut self, args: <a class='struct' href='../../../bitflags/__core/fmt/struct.Arguments.html' title='bitflags::__core::fmt::Arguments'>Arguments</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>&gt;</code></h4>
</div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.Ord.html' title='bitflags::__core::cmp::Ord'>Ord</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.cmp' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='enum' href='../../../bitflags/__core/cmp/enum.Ordering.html' title='bitflags::__core::cmp::Ordering'>Ordering</a></code></h4>
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'></div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialOrd.html' title='bitflags::__core::cmp::PartialOrd'>PartialOrd</a>&lt;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>&gt; for <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a></code></h3><div class='impl-items'><h4 id='method.partial_cmp' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;<a class='enum' href='../../../bitflags/__core/cmp/enum.Ordering.html' title='bitflags::__core::cmp::Ordering'>Ordering</a>&gt;</code></h4>
<h4 id='method.lt' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.le' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.gt' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.ge' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
</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>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</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>
</div>
</div>
</aside>
<script>
window.rootPath = "../../../";
window.currentCrate = "bitflags";
window.playgroundUrl = "";
</script>
<script src="../../../jquery.js"></script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>