Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 0c2243f8a1696816431e7210e991fa52 > files > 15616

rust-doc-1.35.0-1.mga7.armv7hl.rpm

<!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 `IoVec` struct in crate `std`."><meta name="keywords" content="rust, rustlang, rust-lang, IoVec"><title>std::io::IoVec - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize1.35.0.css"><link rel="stylesheet" type="text/css" href="../../rustdoc1.35.0.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark1.35.0.css"><link rel="stylesheet" type="text/css" href="../../light1.35.0.css" id="themeStyle"><script src="../../storage1.35.0.js"></script><noscript><link rel="stylesheet" href="../../noscript1.35.0.css"></noscript><link rel="shortcut icon" href="../../favicon1.35.0.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow1.35.0.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../std/index.html'><img src='../../rust-logo1.35.0.png' alt='logo' width='100'></a><p class='location'>Struct IoVec</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a></div><a class="sidebar-title" href="#deref-methods">Methods from Deref&lt;Target=[u8]&gt;</a><div class="sidebar-links"><a href="#method.align_to">align_to</a><a href="#method.as_ptr">as_ptr</a><a href="#method.binary_search">binary_search</a><a href="#method.binary_search_by">binary_search_by</a><a href="#method.binary_search_by_key">binary_search_by_key</a><a href="#method.chunks">chunks</a><a href="#method.chunks_exact">chunks_exact</a><a href="#method.contains">contains</a><a href="#method.ends_with">ends_with</a><a href="#method.eq_ignore_ascii_case">eq_ignore_ascii_case</a><a href="#method.first">first</a><a href="#method.get">get</a><a href="#method.get_unchecked">get_unchecked</a><a href="#method.is_ascii">is_ascii</a><a href="#method.is_empty">is_empty</a><a href="#method.is_sorted">is_sorted</a><a href="#method.is_sorted_by">is_sorted_by</a><a href="#method.is_sorted_by_key">is_sorted_by_key</a><a href="#method.iter">iter</a><a href="#method.last">last</a><a href="#method.len">len</a><a href="#method.rchunks">rchunks</a><a href="#method.rchunks_exact">rchunks_exact</a><a href="#method.repeat">repeat</a><a href="#method.rsplit">rsplit</a><a href="#method.rsplitn">rsplitn</a><a href="#method.split">split</a><a href="#method.split_at">split_at</a><a href="#method.split_first">split_first</a><a href="#method.split_last">split_last</a><a href="#method.splitn">splitn</a><a href="#method.starts_with">starts_with</a><a href="#method.to_ascii_lowercase">to_ascii_lowercase</a><a href="#method.to_ascii_uppercase">to_ascii_uppercase</a><a href="#method.to_vec">to_vec</a><a href="#method.windows">windows</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Deref">Deref</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow">Borrow</a><a href="#impl-BorrowMut">BorrowMut</a><a href="#impl-From">From</a><a href="#impl-Into">Into</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-TryInto">TryInto</a></div></div><p class='location'><a href='../index.html'>std</a>::<wbr><a href='index.html'>io</a></p><script>window.sidebarCurrent = {name: 'IoVec', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush1.35.0.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme1.35.0.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel1.35.0.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span class='since' title='Stable since Rust version '></span><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 class='srclink' href='../../src/std/io/mod.rs.html#963' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='../index.html'>std</a>::<wbr><a href='index.html'>io</a>::<wbr><a class="struct" href=''>IoVec</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'><div class="docblock attributes">#[repr(transparent)]
</div>pub struct IoVec&lt;'a&gt;(_);</pre></div><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>iovec</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/58452">#58452</a>)</div></div><div class='docblock'><p>A buffer type used with <code>Write::write_vectored</code>.</p>
<p>It is semantically a wrapper around an <code>&amp;[u8]</code>, but is guaranteed to be
ABI compatible with the <code>iovec</code> type on Unix platforms and <code>WSABUF</code> on
Windows.</p>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="struct" href="../../std/io/struct.IoVec.html" title="struct std::io::IoVec">IoVec</a>&lt;'a&gt;</code><a href='#impl' class='anchor'></a><a class='srclink' href='../../src/std/io/mod.rs.html#972-983' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a>(buf: <a class="primitive" href="../primitive.slice.html">&amp;'a [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -&gt; <a class="struct" href="../../std/io/struct.IoVec.html" title="struct std::io::IoVec">IoVec</a>&lt;'a&gt;</code><a class='srclink' href='../../src/std/io/mod.rs.html#980-982' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>iovec</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/58452">#58452</a>)</div></div><div class='docblock'><p>Creates a new <code>IoVec</code> wrapping a byte slice.</p>
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
<p>Panics on Windows if the slice is larger than 4GB.</p>
</div></div><h2 id='deref-methods' class='small-section-header'>Methods from <a class="trait" href="../../std/ops/trait.Deref.html" title="trait std::ops::Deref">Deref</a>&lt;Target = <a class="primitive" href="../primitive.slice.html">[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>&gt;<a href='#deref-methods' class='anchor'></a></h2><div class='impl-items'><h4 id='method.len' class="method"><code id='len.v'>pub fn <a href='#method.len' class='fnname'>len</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.usize.html">usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#77-81' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the number of elements in the slice.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</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>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20a%20%3D%20%5B1%2C%202%2C%203%5D%3B%0Aassert_eq!(a.len()%2C%203)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.is_empty' class="method"><code id='is_empty.v'>pub fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#94-96' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if the slice has a length of 0.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">a</span>.<span class="ident">is_empty</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20a%20%3D%20%5B1%2C%202%2C%203%5D%3B%0Aassert!(!a.is_empty())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.first' class="method"><code id='first.v'>pub fn <a href='#method.first' class='fnname'>first</a>(&amp;self) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;<a class="primitive" href="../primitive.reference.html">&amp;</a>T&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#111-113' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the first element of the slice, or <code>None</code> if it is empty.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">10</span>), <span class="ident">v</span>.<span class="ident">first</span>());

<span class="kw">let</span> <span class="ident">w</span>: <span class="kw-2">&amp;</span>[<span class="ident">i32</span>] <span class="op">=</span> <span class="kw-2">&amp;</span>[];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">w</span>.<span class="ident">first</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Aassert_eq!(Some(%2610)%2C%20v.first())%3B%0A%0Alet%20w%3A%20%26%5Bi32%5D%20%3D%20%26%5B%5D%3B%0Aassert_eq!(None%2C%20w.first())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.split_first' class="method"><code id='split_first.v'>pub fn <a href='#method.split_first' class='fnname'>split_first</a>(&amp;self) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;<a class="primitive" href="../primitive.tuple.html">(</a><a class="primitive" href="../primitive.reference.html">&amp;</a>T, <a class="primitive" href="../primitive.slice.html">&amp;[T]</a><a class="primitive" href="../primitive.tuple.html">)</a>&gt;</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#147-149' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the first and all the rest of the elements of the slice, or <code>None</code> if it is empty.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>];

<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>((<span class="ident">first</span>, <span class="ident">elements</span>)) <span class="op">=</span> <span class="ident">x</span>.<span class="ident">split_first</span>() {
    <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">first</span>, <span class="kw-2">&amp;</span><span class="number">0</span>);
    <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">elements</span>, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>]);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20x%20%3D%20%26%5B0%2C%201%2C%202%5D%3B%0A%0Aif%20let%20Some((first%2C%20elements))%20%3D%20x.split_first()%20%7B%0A%20%20%20%20assert_eq!(first%2C%20%260)%3B%0A%20%20%20%20assert_eq!(elements%2C%20%26%5B1%2C%202%5D)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.split_last' class="method"><code id='split_last.v'>pub fn <a href='#method.split_last' class='fnname'>split_last</a>(&amp;self) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;<a class="primitive" href="../primitive.tuple.html">(</a><a class="primitive" href="../primitive.reference.html">&amp;</a>T, <a class="primitive" href="../primitive.slice.html">&amp;[T]</a><a class="primitive" href="../primitive.tuple.html">)</a>&gt;</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#188-191' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the last and all the rest of the elements of the slice, or <code>None</code> if it is empty.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>];

<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>((<span class="ident">last</span>, <span class="ident">elements</span>)) <span class="op">=</span> <span class="ident">x</span>.<span class="ident">split_last</span>() {
    <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">last</span>, <span class="kw-2">&amp;</span><span class="number">2</span>);
    <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">elements</span>, <span class="kw-2">&amp;</span>[<span class="number">0</span>, <span class="number">1</span>]);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20x%20%3D%20%26%5B0%2C%201%2C%202%5D%3B%0A%0Aif%20let%20Some((last%2C%20elements))%20%3D%20x.split_last()%20%7B%0A%20%20%20%20assert_eq!(last%2C%20%262)%3B%0A%20%20%20%20assert_eq!(elements%2C%20%26%5B0%2C%201%5D)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.last' class="method"><code id='last.v'>pub fn <a href='#method.last' class='fnname'>last</a>(&amp;self) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;<a class="primitive" href="../primitive.reference.html">&amp;</a>T&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#231-234' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the last element of the slice, or <code>None</code> if it is empty.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">30</span>), <span class="ident">v</span>.<span class="ident">last</span>());

<span class="kw">let</span> <span class="ident">w</span>: <span class="kw-2">&amp;</span>[<span class="ident">i32</span>] <span class="op">=</span> <span class="kw-2">&amp;</span>[];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">w</span>.<span class="ident">last</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Aassert_eq!(Some(%2630)%2C%20v.last())%3B%0A%0Alet%20w%3A%20%26%5Bi32%5D%20%3D%20%26%5B%5D%3B%0Aassert_eq!(None%2C%20w.last())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.get' class="method"><code id='get.v'>pub fn <a href='#method.get' class='fnname'>get</a>&lt;I&gt;(&amp;self, index: I) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;&amp;&lt;I as <a class="trait" href="../../std/slice/trait.SliceIndex.html" title="trait std::slice::SliceIndex">SliceIndex</a>&lt;<a class="primitive" href="../primitive.slice.html">[</a>T<a class="primitive" href="../primitive.slice.html">]</a>&gt;&gt;::<a class="type" href="../../std/slice/trait.SliceIndex.html#associatedtype.Output" title="type std::slice::SliceIndex::Output">Output</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="../../std/slice/trait.SliceIndex.html" title="trait std::slice::SliceIndex">SliceIndex</a>&lt;<a class="primitive" href="../primitive.slice.html">[</a>T<a class="primitive" href="../primitive.slice.html">]</a>&gt;,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#274-278' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a reference to an element or subslice depending on the type of
index.</p>
<ul>
<li>If given a position, returns a reference to the element at that
position or <code>None</code> if out of bounds.</li>
<li>If given a range, returns the subslice corresponding to that range,
or <code>None</code> if out of bounds.</li>
</ul>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">40</span>), <span class="ident">v</span>.<span class="ident">get</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">40</span>][..]), <span class="ident">v</span>.<span class="ident">get</span>(<span class="number">0</span>..<span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">v</span>.<span class="ident">get</span>(<span class="number">3</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">v</span>.<span class="ident">get</span>(<span class="number">0</span>..<span class="number">4</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Aassert_eq!(Some(%2640)%2C%20v.get(1))%3B%0Aassert_eq!(Some(%26%5B10%2C%2040%5D%5B..%5D)%2C%20v.get(0..2))%3B%0Aassert_eq!(None%2C%20v.get(3))%3B%0Aassert_eq!(None%2C%20v.get(0..4))%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.get_unchecked' class="method"><code id='get_unchecked.v'>pub unsafe fn <a href='#method.get_unchecked' class='fnname'>get_unchecked</a>&lt;I&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;index: I<br>) -&gt; &amp;&lt;I as <a class="trait" href="../../std/slice/trait.SliceIndex.html" title="trait std::slice::SliceIndex">SliceIndex</a>&lt;<a class="primitive" href="../primitive.slice.html">[</a>T<a class="primitive" href="../primitive.slice.html">]</a>&gt;&gt;::<a class="type" href="../../std/slice/trait.SliceIndex.html#associatedtype.Output" title="type std::slice::SliceIndex::Output">Output</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="../../std/slice/trait.SliceIndex.html" title="trait std::slice::SliceIndex">SliceIndex</a>&lt;<a class="primitive" href="../primitive.slice.html">[</a>T<a class="primitive" href="../primitive.slice.html">]</a>&gt;,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#322-326' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a reference to an element or subslice, without doing bounds
checking.</p>
<p>This is generally not recommended, use with caution! For a safe
alternative see <a href="#method.get"><code>get</code></a>.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>];

<span class="kw">unsafe</span> {
    <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>.<span class="ident">get_unchecked</span>(<span class="number">1</span>), <span class="kw-2">&amp;</span><span class="number">2</span>);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20x%20%3D%20%26%5B1%2C%202%2C%204%5D%3B%0A%0Aunsafe%20%7B%0A%20%20%20%20assert_eq!(x.get_unchecked(1)%2C%20%262)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.as_ptr' class="method"><code id='as_ptr.v'>pub const fn <a href='#method.as_ptr' class='fnname'>as_ptr</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.pointer.html">*const T</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#377-379' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a raw pointer to the slice's buffer.</p>
<p>The caller must ensure that the slice outlives the pointer this
function returns, or else it will end up pointing to garbage.</p>
<p>Modifying the container referenced by this slice may cause its buffer
to be reallocated, which would also make any pointers to it invalid.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>];
<span class="kw">let</span> <span class="ident">x_ptr</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">as_ptr</span>();

<span class="kw">unsafe</span> {
    <span class="kw">for</span> <span class="ident">i</span> <span class="kw">in</span> <span class="number">0</span>..<span class="ident">x</span>.<span class="ident">len</span>() {
        <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>.<span class="ident">get_unchecked</span>(<span class="ident">i</span>), <span class="kw-2">&amp;</span><span class="kw-2">*</span><span class="ident">x_ptr</span>.<span class="ident">add</span>(<span class="ident">i</span>));
    }
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20x%20%3D%20%26%5B1%2C%202%2C%204%5D%3B%0Alet%20x_ptr%20%3D%20x.as_ptr()%3B%0A%0Aunsafe%20%7B%0A%20%20%20%20for%20i%20in%200..x.len()%20%7B%0A%20%20%20%20%20%20%20%20assert_eq!(x.get_unchecked(i)%2C%20%26*x_ptr.add(i))%3B%0A%20%20%20%20%7D%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.iter' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.Iter.html" title="struct std::slice::Iter">Iter</a>&lt;'a, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.Iter.html" title="struct std::slice::Iter">Iter</a>&lt;'a, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.Iter.html" title="struct std::slice::Iter">Iter</a>&lt;'a, T&gt;</span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.reference.html">&amp;'a </a>T;</span></code></div></div><code id='iter.v'>pub fn <a href='#method.iter' class='fnname'>iter</a>(&amp;self) -&gt; <a class="struct" href="../../std/slice/struct.Iter.html" title="struct std::slice::Iter">Iter</a>&lt;T&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#527-544' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over the slice.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iterator</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">iter</span>();

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iterator</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iterator</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iterator</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">4</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iterator</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20x%20%3D%20%26%5B1%2C%202%2C%204%5D%3B%0Alet%20mut%20iterator%20%3D%20x.iter()%3B%0A%0Aassert_eq!(iterator.next()%2C%20Some(%261))%3B%0Aassert_eq!(iterator.next()%2C%20Some(%262))%3B%0Aassert_eq!(iterator.next()%2C%20Some(%264))%3B%0Aassert_eq!(iterator.next()%2C%20None)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.windows' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.Windows.html" title="struct std::slice::Windows">Windows</a>&lt;'a, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.Windows.html" title="struct std::slice::Windows">Windows</a>&lt;'a, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.Windows.html" title="struct std::slice::Windows">Windows</a>&lt;'a, T&gt;</span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='windows.v'>pub fn <a href='#method.windows' class='fnname'>windows</a>(&amp;self, size: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../../std/slice/struct.Windows.html" title="struct std::slice::Windows">Windows</a>&lt;T&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#606-609' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over all contiguous windows of length
<code>size</code>. The windows overlap. If the slice is shorter than
<code>size</code>, the iterator returns no values.</p>
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
<p>Panics if <code>size</code> is 0.</p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="string">&#39;r&#39;</span>, <span class="string">&#39;u&#39;</span>, <span class="string">&#39;s&#39;</span>, <span class="string">&#39;t&#39;</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">windows</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;r&#39;</span>, <span class="string">&#39;u&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;u&#39;</span>, <span class="string">&#39;s&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;s&#39;</span>, <span class="string">&#39;t&#39;</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B'r'%2C%20'u'%2C%20's'%2C%20't'%5D%3B%0Alet%20mut%20iter%20%3D%20slice.windows(2)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'r'%2C%20'u'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'u'%2C%20's'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B's'%2C%20't'%5D)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
<p>If the slice is shorter than <code>size</code>:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="string">&#39;f&#39;</span>, <span class="string">&#39;o&#39;</span>, <span class="string">&#39;o&#39;</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">windows</span>(<span class="number">4</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B'f'%2C%20'o'%2C%20'o'%5D%3B%0Alet%20mut%20iter%20%3D%20slice.windows(4)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.chunks' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.Chunks.html" title="struct std::slice::Chunks">Chunks</a>&lt;'a, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.Chunks.html" title="struct std::slice::Chunks">Chunks</a>&lt;'a, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.Chunks.html" title="struct std::slice::Chunks">Chunks</a>&lt;'a, T&gt;</span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='chunks.v'>pub fn <a href='#method.chunks' class='fnname'>chunks</a>(&amp;self, chunk_size: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../../std/slice/struct.Chunks.html" title="struct std::slice::Chunks">Chunks</a>&lt;T&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#640-643' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over <code>chunk_size</code> elements of the slice at a time, starting at the
beginning of the slice.</p>
<p>The chunks are slices and do not overlap. If <code>chunk_size</code> does not divide the length of the
slice, then the last chunk will not have length <code>chunk_size</code>.</p>
<p>See <a href="#method.chunks_exact"><code>chunks_exact</code></a> for a variant of this iterator that returns chunks of always exactly
<code>chunk_size</code> elements, and <a href="#method.rchunks"><code>rchunks</code></a> for the same iterator but starting at the end of the
slice of the slice.</p>
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
<p>Panics if <code>chunk_size</code> is 0.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="string">&#39;l&#39;</span>, <span class="string">&#39;o&#39;</span>, <span class="string">&#39;r&#39;</span>, <span class="string">&#39;e&#39;</span>, <span class="string">&#39;m&#39;</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">chunks</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;l&#39;</span>, <span class="string">&#39;o&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;r&#39;</span>, <span class="string">&#39;e&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;m&#39;</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B'l'%2C%20'o'%2C%20'r'%2C%20'e'%2C%20'm'%5D%3B%0Alet%20mut%20iter%20%3D%20slice.chunks(2)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'l'%2C%20'o'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'r'%2C%20'e'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'm'%5D)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.chunks_exact' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.ChunksExact.html" title="struct std::slice::ChunksExact">ChunksExact</a>&lt;'a, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.ChunksExact.html" title="struct std::slice::ChunksExact">ChunksExact</a>&lt;'a, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.ChunksExact.html" title="struct std::slice::ChunksExact">ChunksExact</a>&lt;'a, T&gt;</span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='chunks_exact.v'>pub fn <a href='#method.chunks_exact' class='fnname'>chunks_exact</a>(&amp;self, chunk_size: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../../std/slice/struct.ChunksExact.html" title="struct std::slice::ChunksExact">ChunksExact</a>&lt;T&gt;</code><div class='since' title='Stable since Rust version 1.31.0'>1.31.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#715-721' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over <code>chunk_size</code> elements of the slice at a time, starting at the
beginning of the slice.</p>
<p>The chunks are slices and do not overlap. If <code>chunk_size</code> does not divide the length of the
slice, then the last up to <code>chunk_size-1</code> elements will be omitted and can be retrieved
from the <code>remainder</code> function of the iterator.</p>
<p>Due to each chunk having exactly <code>chunk_size</code> elements, the compiler can often optimize the
resulting code better than in the case of <a href="#method.chunks"><code>chunks</code></a>.</p>
<p>See <a href="#method.chunks"><code>chunks</code></a> for a variant of this iterator that also returns the remainder as a smaller
chunk, and <a href="#method.rchunks_exact"><code>rchunks_exact</code></a> for the same iterator but starting at the end of the slice.</p>
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
<p>Panics if <code>chunk_size</code> is 0.</p>
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="string">&#39;l&#39;</span>, <span class="string">&#39;o&#39;</span>, <span class="string">&#39;r&#39;</span>, <span class="string">&#39;e&#39;</span>, <span class="string">&#39;m&#39;</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">chunks_exact</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;l&#39;</span>, <span class="string">&#39;o&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;r&#39;</span>, <span class="string">&#39;e&#39;</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">remainder</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;m&#39;</span>]);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B'l'%2C%20'o'%2C%20'r'%2C%20'e'%2C%20'm'%5D%3B%0Alet%20mut%20iter%20%3D%20slice.chunks_exact(2)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'l'%2C%20'o'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'r'%2C%20'e'%5D)%3B%0Aassert!(iter.next().is_none())%3B%0Aassert_eq!(iter.remainder()%2C%20%26%5B'm'%5D)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.rchunks' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.RChunks.html" title="struct std::slice::RChunks">RChunks</a>&lt;'a, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.RChunks.html" title="struct std::slice::RChunks">RChunks</a>&lt;'a, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.RChunks.html" title="struct std::slice::RChunks">RChunks</a>&lt;'a, T&gt;</span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='rchunks.v'>pub fn <a href='#method.rchunks' class='fnname'>rchunks</a>(&amp;self, chunk_size: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../../std/slice/struct.RChunks.html" title="struct std::slice::RChunks">RChunks</a>&lt;T&gt;</code><div class='since' title='Stable since Rust version 1.31.0'>1.31.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#797-800' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over <code>chunk_size</code> elements of the slice at a time, starting at the end
of the slice.</p>
<p>The chunks are slices and do not overlap. If <code>chunk_size</code> does not divide the length of the
slice, then the last chunk will not have length <code>chunk_size</code>.</p>
<p>See <a href="#method.rchunks_exact"><code>rchunks_exact</code></a> for a variant of this iterator that returns chunks of always exactly
<code>chunk_size</code> elements, and <a href="#method.chunks"><code>chunks</code></a> for the same iterator but starting at the beginning
of the slice.</p>
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
<p>Panics if <code>chunk_size</code> is 0.</p>
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="string">&#39;l&#39;</span>, <span class="string">&#39;o&#39;</span>, <span class="string">&#39;r&#39;</span>, <span class="string">&#39;e&#39;</span>, <span class="string">&#39;m&#39;</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">rchunks</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;e&#39;</span>, <span class="string">&#39;m&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;o&#39;</span>, <span class="string">&#39;r&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;l&#39;</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B'l'%2C%20'o'%2C%20'r'%2C%20'e'%2C%20'm'%5D%3B%0Alet%20mut%20iter%20%3D%20slice.rchunks(2)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'e'%2C%20'm'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'o'%2C%20'r'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'l'%5D)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.rchunks_exact' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.RChunksExact.html" title="struct std::slice::RChunksExact">RChunksExact</a>&lt;'a, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.RChunksExact.html" title="struct std::slice::RChunksExact">RChunksExact</a>&lt;'a, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.RChunksExact.html" title="struct std::slice::RChunksExact">RChunksExact</a>&lt;'a, T&gt;</span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='rchunks_exact.v'>pub fn <a href='#method.rchunks_exact' class='fnname'>rchunks_exact</a>(&amp;self, chunk_size: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../../std/slice/struct.RChunksExact.html" title="struct std::slice::RChunksExact">RChunksExact</a>&lt;T&gt;</code><div class='since' title='Stable since Rust version 1.31.0'>1.31.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#874-879' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over <code>chunk_size</code> elements of the slice at a time, starting at the
beginning of the slice.</p>
<p>The chunks are slices and do not overlap. If <code>chunk_size</code> does not divide the length of the
slice, then the last up to <code>chunk_size-1</code> elements will be omitted and can be retrieved
from the <code>remainder</code> function of the iterator.</p>
<p>Due to each chunk having exactly <code>chunk_size</code> elements, the compiler can often optimize the
resulting code better than in the case of <a href="#method.chunks"><code>chunks</code></a>.</p>
<p>See <a href="#method.rchunks"><code>rchunks</code></a> for a variant of this iterator that also returns the remainder as a smaller
chunk, and <a href="#method.chunks_exact"><code>chunks_exact</code></a> for the same iterator but starting at the beginning of the
slice of the slice.</p>
<h1 id="panics-5" class="section-header"><a href="#panics-5">Panics</a></h1>
<p>Panics if <code>chunk_size</code> is 0.</p>
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="string">&#39;l&#39;</span>, <span class="string">&#39;o&#39;</span>, <span class="string">&#39;r&#39;</span>, <span class="string">&#39;e&#39;</span>, <span class="string">&#39;m&#39;</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">rchunks_exact</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;e&#39;</span>, <span class="string">&#39;m&#39;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;o&#39;</span>, <span class="string">&#39;r&#39;</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">remainder</span>(), <span class="kw-2">&amp;</span>[<span class="string">&#39;l&#39;</span>]);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B'l'%2C%20'o'%2C%20'r'%2C%20'e'%2C%20'm'%5D%3B%0Alet%20mut%20iter%20%3D%20slice.rchunks_exact(2)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'e'%2C%20'm'%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B'o'%2C%20'r'%5D)%3B%0Aassert!(iter.next().is_none())%3B%0Aassert_eq!(iter.remainder()%2C%20%26%5B'l'%5D)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.split_at' class="method"><code id='split_at.v'>pub fn <a href='#method.split_at' class='fnname'>split_at</a>(&amp;self, mid: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="../primitive.tuple.html">(</a><a class="primitive" href="../primitive.slice.html">&amp;[T]</a>, <a class="primitive" href="../primitive.slice.html">&amp;[T]</a><a class="primitive" href="../primitive.tuple.html">)</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#961-963' title='goto source code'>[src]</a></h4><div class='docblock'><p>Divides one slice into two at an index.</p>
<p>The first will contain all indices from <code>[0, mid)</code> (excluding
the index <code>mid</code> itself) and the second will contain all
indices from <code>[mid, len)</code> (excluding the index <code>len</code> itself).</p>
<h1 id="panics-6" class="section-header"><a href="#panics-6">Panics</a></h1>
<p>Panics if <code>mid &gt; len</code>.</p>
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>];

{
   <span class="kw">let</span> (<span class="ident">left</span>, <span class="ident">right</span>) <span class="op">=</span> <span class="ident">v</span>.<span class="ident">split_at</span>(<span class="number">0</span>);
   <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">left</span> <span class="op">==</span> []);
   <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">right</span> <span class="op">==</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
}

{
    <span class="kw">let</span> (<span class="ident">left</span>, <span class="ident">right</span>) <span class="op">=</span> <span class="ident">v</span>.<span class="ident">split_at</span>(<span class="number">2</span>);
    <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">left</span> <span class="op">==</span> [<span class="number">1</span>, <span class="number">2</span>]);
    <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">right</span> <span class="op">==</span> [<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
}

{
    <span class="kw">let</span> (<span class="ident">left</span>, <span class="ident">right</span>) <span class="op">=</span> <span class="ident">v</span>.<span class="ident">split_at</span>(<span class="number">6</span>);
    <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">left</span> <span class="op">==</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
    <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">right</span> <span class="op">==</span> []);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D%3B%0A%0A%7B%0A%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at(0)%3B%0A%20%20%20assert!(left%20%3D%3D%20%5B%5D)%3B%0A%20%20%20assert!(right%20%3D%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D)%3B%0A%7D%0A%0A%7B%0A%20%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at(2)%3B%0A%20%20%20%20assert!(left%20%3D%3D%20%5B1%2C%202%5D)%3B%0A%20%20%20%20assert!(right%20%3D%3D%20%5B3%2C%204%2C%205%2C%206%5D)%3B%0A%7D%0A%0A%7B%0A%20%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at(6)%3B%0A%20%20%20%20assert!(left%20%3D%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D)%3B%0A%20%20%20%20assert!(right%20%3D%3D%20%5B%5D)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.split' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.Split.html" title="struct std::slice::Split">Split</a>&lt;'a, T, P&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.Split.html" title="struct std::slice::Split">Split</a>&lt;'a, T, P&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, P&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.Split.html" title="struct std::slice::Split">Split</a>&lt;'a, T, P&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='split.v'>pub fn <a href='#method.split' class='fnname'>split</a>&lt;F&gt;(&amp;self, pred: F) -&gt; <a class="struct" href="../../std/slice/struct.Split.html" title="struct std::slice::Split">Split</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1045-1053' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over subslices separated by elements that match
<code>pred</code>. The matched element is not contained in the subslices.</p>
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">33</span>, <span class="number">20</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">split</span>(<span class="op">|</span><span class="ident">num</span><span class="op">|</span> <span class="ident">num</span> <span class="op">%</span> <span class="number">3</span> <span class="op">==</span> <span class="number">0</span>);

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">40</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">20</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B10%2C%2040%2C%2033%2C%2020%5D%3B%0Alet%20mut%20iter%20%3D%20slice.split(%7Cnum%7C%20num%20%25%203%20%3D%3D%200)%3B%0A%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B10%2C%2040%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B20%5D)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
<p>If the first element is matched, an empty slice will be the first item
returned by the iterator. Similarly, if the last element in the slice
is matched, an empty slice will be the last item returned by the
iterator:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">33</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">split</span>(<span class="op">|</span><span class="ident">num</span><span class="op">|</span> <span class="ident">num</span> <span class="op">%</span> <span class="number">3</span> <span class="op">==</span> <span class="number">0</span>);

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">40</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B10%2C%2040%2C%2033%5D%3B%0Alet%20mut%20iter%20%3D%20slice.split(%7Cnum%7C%20num%20%25%203%20%3D%3D%200)%3B%0A%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B10%2C%2040%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B%5D)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
<p>If two matched elements are directly adjacent, an empty slice will be
present between them:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">6</span>, <span class="number">33</span>, <span class="number">20</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">split</span>(<span class="op">|</span><span class="ident">num</span><span class="op">|</span> <span class="ident">num</span> <span class="op">%</span> <span class="number">3</span> <span class="op">==</span> <span class="number">0</span>);

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">10</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">20</span>]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B10%2C%206%2C%2033%2C%2020%5D%3B%0Alet%20mut%20iter%20%3D%20slice.split(%7Cnum%7C%20num%20%25%203%20%3D%3D%200)%3B%0A%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B10%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B20%5D)%3B%0Aassert!(iter.next().is_none())%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.rsplit' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.RSplit.html" title="struct std::slice::RSplit">RSplit</a>&lt;'a, T, P&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.RSplit.html" title="struct std::slice::RSplit">RSplit</a>&lt;'a, T, P&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, P&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.RSplit.html" title="struct std::slice::RSplit">RSplit</a>&lt;'a, T, P&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='rsplit.v'>pub fn <a href='#method.rsplit' class='fnname'>rsplit</a>&lt;F&gt;(&amp;self, pred: F) -&gt; <a class="struct" href="../../std/slice/struct.RSplit.html" title="struct std::slice::RSplit">RSplit</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.27.0'>1.27.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1105-1109' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over subslices separated by elements that match
<code>pred</code>, starting at the end of the slice and working backwards.
The matched element is not contained in the subslices.</p>
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> [<span class="number">11</span>, <span class="number">22</span>, <span class="number">33</span>, <span class="number">0</span>, <span class="number">44</span>, <span class="number">55</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">slice</span>.<span class="ident">rsplit</span>(<span class="op">|</span><span class="ident">num</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">num</span> <span class="op">==</span> <span class="number">0</span>);

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">44</span>, <span class="number">55</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">11</span>, <span class="number">22</span>, <span class="number">33</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">iter</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20slice%20%3D%20%5B11%2C%2022%2C%2033%2C%200%2C%2044%2C%2055%5D%3B%0Alet%20mut%20iter%20%3D%20slice.rsplit(%7Cnum%7C%20*num%20%3D%3D%200)%3B%0A%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B44%2C%2055%5D)%3B%0Aassert_eq!(iter.next().unwrap()%2C%20%26%5B11%2C%2022%2C%2033%5D)%3B%0Aassert_eq!(iter.next()%2C%20None)%3B%0A%7D">Run</a></pre></div>
<p>As with <code>split()</code>, if the first or last element is matched, an empty
slice will be the first (or last) item returned by the iterator.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">it</span> <span class="op">=</span> <span class="ident">v</span>.<span class="ident">rsplit</span>(<span class="op">|</span><span class="ident">n</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">n</span> <span class="op">%</span> <span class="number">2</span> <span class="op">==</span> <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">3</span>, <span class="number">5</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">1</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&amp;</span>[]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%26%5B0%2C%201%2C%201%2C%202%2C%203%2C%205%2C%208%5D%3B%0Alet%20mut%20it%20%3D%20v.rsplit(%7Cn%7C%20*n%20%25%202%20%3D%3D%200)%3B%0Aassert_eq!(it.next().unwrap()%2C%20%26%5B%5D)%3B%0Aassert_eq!(it.next().unwrap()%2C%20%26%5B3%2C%205%5D)%3B%0Aassert_eq!(it.next().unwrap()%2C%20%26%5B1%2C%201%5D)%3B%0Aassert_eq!(it.next().unwrap()%2C%20%26%5B%5D)%3B%0Aassert_eq!(it.next()%2C%20None)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.splitn' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.SplitN.html" title="struct std::slice::SplitN">SplitN</a>&lt;'a, T, P&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.SplitN.html" title="struct std::slice::SplitN">SplitN</a>&lt;'a, T, P&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, P&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.SplitN.html" title="struct std::slice::SplitN">SplitN</a>&lt;'a, T, P&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='splitn.v'>pub fn <a href='#method.splitn' class='fnname'>splitn</a>&lt;F&gt;(&amp;self, n: <a class="primitive" href="../primitive.usize.html">usize</a>, pred: F) -&gt; <a class="struct" href="../../std/slice/struct.SplitN.html" title="struct std::slice::SplitN">SplitN</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1157-1166' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over subslices separated by elements that match
<code>pred</code>, limited to returning at most <code>n</code> items. The matched element is
not contained in the subslices.</p>
<p>The last element returned, if any, will contain the remainder of the
slice.</p>
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
<p>Print the slice split once by numbers divisible by 3 (i.e., <code>[10, 40]</code>,
<code>[20, 60, 50]</code>):</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>, <span class="number">20</span>, <span class="number">60</span>, <span class="number">50</span>];

<span class="kw">for</span> <span class="ident">group</span> <span class="kw">in</span> <span class="ident">v</span>.<span class="ident">splitn</span>(<span class="number">2</span>, <span class="op">|</span><span class="ident">num</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">num</span> <span class="op">%</span> <span class="number">3</span> <span class="op">==</span> <span class="number">0</span>) {
    <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">group</span>);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%2C%2020%2C%2060%2C%2050%5D%3B%0A%0Afor%20group%20in%20v.splitn(2%2C%20%7Cnum%7C%20*num%20%25%203%20%3D%3D%200)%20%7B%0A%20%20%20%20println!(%22%7B%3A%3F%7D%22%2C%20group)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.rsplitn' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/slice/struct.RSplitN.html" title="struct std::slice::RSplitN">RSplitN</a>&lt;'a, T, P&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/slice/struct.RSplitN.html" title="struct std::slice::RSplitN">RSplitN</a>&lt;'a, T, P&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, P&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="struct" href="../../std/slice/struct.RSplitN.html" title="struct std::slice::RSplitN">RSplitN</a>&lt;'a, T, P&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="../primitive.slice.html">&amp;'a [T]</a>;</span></code></div></div><code id='rsplitn.v'>pub fn <a href='#method.rsplitn' class='fnname'>rsplitn</a>&lt;F&gt;(&amp;self, n: <a class="primitive" href="../primitive.usize.html">usize</a>, pred: F) -&gt; <a class="struct" href="../../std/slice/struct.RSplitN.html" title="struct std::slice::RSplitN">RSplitN</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1220-1229' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over subslices separated by elements that match
<code>pred</code> limited to returning at most <code>n</code> items. This starts at the end of
the slice and works backwards. The matched element is not contained in
the subslices.</p>
<p>The last element returned, if any, will contain the remainder of the
slice.</p>
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
<p>Print the slice split once, starting from the end, by numbers divisible
by 3 (i.e., <code>[50]</code>, <code>[10, 40, 30, 20]</code>):</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>, <span class="number">20</span>, <span class="number">60</span>, <span class="number">50</span>];

<span class="kw">for</span> <span class="ident">group</span> <span class="kw">in</span> <span class="ident">v</span>.<span class="ident">rsplitn</span>(<span class="number">2</span>, <span class="op">|</span><span class="ident">num</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">num</span> <span class="op">%</span> <span class="number">3</span> <span class="op">==</span> <span class="number">0</span>) {
    <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">group</span>);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%2C%2020%2C%2060%2C%2050%5D%3B%0A%0Afor%20group%20in%20v.rsplitn(2%2C%20%7Cnum%7C%20*num%20%25%203%20%3D%3D%200)%20%7B%0A%20%20%20%20println!(%22%7B%3A%3F%7D%22%2C%20group)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.contains' class="method"><code id='contains.v'>pub fn <a href='#method.contains' class='fnname'>contains</a>(&amp;self, x: <a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/cmp/trait.PartialEq.html" title="trait std::cmp::PartialEq">PartialEq</a>&lt;T&gt;,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1272-1276' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if the slice contains an element with the given value.</p>
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="number">30</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="number">50</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Aassert!(v.contains(%2630))%3B%0Aassert!(!v.contains(%2650))%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.starts_with' class="method"><code id='starts_with.v'>pub fn <a href='#method.starts_with' class='fnname'>starts_with</a>(&amp;self, needle: <a class="primitive" href="../primitive.slice.html">&amp;[T]</a>) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/cmp/trait.PartialEq.html" title="trait std::cmp::PartialEq">PartialEq</a>&lt;T&gt;,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1299-1304' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if <code>needle</code> is a prefix of the slice.</p>
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">starts_with</span>(<span class="kw-2">&amp;</span>[<span class="number">10</span>]));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">starts_with</span>(<span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">40</span>]));
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">starts_with</span>(<span class="kw-2">&amp;</span>[<span class="number">50</span>]));
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">starts_with</span>(<span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">50</span>]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Aassert!(v.starts_with(%26%5B10%5D))%3B%0Aassert!(v.starts_with(%26%5B10%2C%2040%5D))%3B%0Aassert!(!v.starts_with(%26%5B50%5D))%3B%0Aassert!(!v.starts_with(%26%5B10%2C%2050%5D))%3B%0A%7D">Run</a></pre></div>
<p>Always returns <code>true</code> if <code>needle</code> is an empty slice:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">starts_with</span>(<span class="kw-2">&amp;</span>[]));
<span class="kw">let</span> <span class="ident">v</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>] <span class="op">=</span> <span class="kw-2">&amp;</span>[];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">starts_with</span>(<span class="kw-2">&amp;</span>[]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%26%5B10%2C%2040%2C%2030%5D%3B%0Aassert!(v.starts_with(%26%5B%5D))%3B%0Alet%20v%3A%20%26%5Bu8%5D%20%3D%20%26%5B%5D%3B%0Aassert!(v.starts_with(%26%5B%5D))%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.ends_with' class="method"><code id='ends_with.v'>pub fn <a href='#method.ends_with' class='fnname'>ends_with</a>(&amp;self, needle: <a class="primitive" href="../primitive.slice.html">&amp;[T]</a>) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/cmp/trait.PartialEq.html" title="trait std::cmp::PartialEq">PartialEq</a>&lt;T&gt;,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1327-1332' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if <code>needle</code> is a suffix of the slice.</p>
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">ends_with</span>(<span class="kw-2">&amp;</span>[<span class="number">30</span>]));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">ends_with</span>(<span class="kw-2">&amp;</span>[<span class="number">40</span>, <span class="number">30</span>]));
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">ends_with</span>(<span class="kw-2">&amp;</span>[<span class="number">50</span>]));
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">ends_with</span>(<span class="kw-2">&amp;</span>[<span class="number">50</span>, <span class="number">30</span>]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Aassert!(v.ends_with(%26%5B30%5D))%3B%0Aassert!(v.ends_with(%26%5B40%2C%2030%5D))%3B%0Aassert!(!v.ends_with(%26%5B50%5D))%3B%0Aassert!(!v.ends_with(%26%5B50%2C%2030%5D))%3B%0A%7D">Run</a></pre></div>
<p>Always returns <code>true</code> if <code>needle</code> is an empty slice:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> <span class="kw-2">&amp;</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">ends_with</span>(<span class="kw-2">&amp;</span>[]));
<span class="kw">let</span> <span class="ident">v</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>] <span class="op">=</span> <span class="kw-2">&amp;</span>[];
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">ends_with</span>(<span class="kw-2">&amp;</span>[]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20v%20%3D%20%26%5B10%2C%2040%2C%2030%5D%3B%0Aassert!(v.ends_with(%26%5B%5D))%3B%0Alet%20v%3A%20%26%5Bu8%5D%20%3D%20%26%5B%5D%3B%0Aassert!(v.ends_with(%26%5B%5D))%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.binary_search' class="method"><code id='binary_search.v'>pub fn <a href='#method.binary_search' class='fnname'>binary_search</a>(&amp;self, x: <a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a>&lt;<a class="primitive" href="../primitive.usize.html">usize</a>, <a class="primitive" href="../primitive.usize.html">usize</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/cmp/trait.Ord.html" title="trait std::cmp::Ord">Ord</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1358-1362' title='goto source code'>[src]</a></h4><div class='docblock'><p>Binary searches this sorted slice for a given element.</p>
<p>If the value is found then <a href="../../std/result/enum.Result.html#Ok.v" title="`Result::Ok`"><code>Result::Ok</code></a> is returned, containing the
index of the matching element. If there are multiple matches, then any
one of the matches could be returned. If the value is not found then
<a href="../../std/result/enum.Result.html#Err.v" title="`Result::Err`"><code>Result::Err</code></a> is returned, containing the index where a matching
element could be inserted while maintaining sorted order.</p>
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
<p>Looks up a series of four elements. The first is found, with a
uniquely determined position; the second and third are not
found; the fourth could match any position in <code>[1, 4]</code>.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> [<span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">13</span>, <span class="number">21</span>, <span class="number">34</span>, <span class="number">55</span>];

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search</span>(<span class="kw-2">&amp;</span><span class="number">13</span>),  <span class="prelude-val">Ok</span>(<span class="number">9</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search</span>(<span class="kw-2">&amp;</span><span class="number">4</span>),   <span class="prelude-val">Err</span>(<span class="number">7</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search</span>(<span class="kw-2">&amp;</span><span class="number">100</span>), <span class="prelude-val">Err</span>(<span class="number">13</span>));
<span class="kw">let</span> <span class="ident">r</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">binary_search</span>(<span class="kw-2">&amp;</span><span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="kw">match</span> <span class="ident">r</span> { <span class="prelude-val">Ok</span>(<span class="number">1</span>..=<span class="number">4</span>) <span class="op">=&gt;</span> <span class="bool-val">true</span>, <span class="kw">_</span> <span class="op">=&gt;</span> <span class="bool-val">false</span>, });<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20s%20%3D%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%202%2C%203%2C%205%2C%208%2C%2013%2C%2021%2C%2034%2C%2055%5D%3B%0A%0Aassert_eq!(s.binary_search(%2613)%2C%20%20Ok(9))%3B%0Aassert_eq!(s.binary_search(%264)%2C%20%20%20Err(7))%3B%0Aassert_eq!(s.binary_search(%26100)%2C%20Err(13))%3B%0Alet%20r%20%3D%20s.binary_search(%261)%3B%0Aassert!(match%20r%20%7B%20Ok(1..%3D4)%20%3D%3E%20true%2C%20_%20%3D%3E%20false%2C%20%7D)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.binary_search_by' class="method"><code id='binary_search_by.v'>pub fn <a href='#method.binary_search_by' class='fnname'>binary_search_by</a>&lt;'a, F&gt;(&amp;'a self, f: F) -&gt; <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a>&lt;<a class="primitive" href="../primitive.usize.html">usize</a>, <a class="primitive" href="../primitive.usize.html">usize</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;'a </a>T) -&gt; <a class="enum" href="../../std/cmp/enum.Ordering.html" title="enum std::cmp::Ordering">Ordering</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1398-1421' title='goto source code'>[src]</a></h4><div class='docblock'><p>Binary searches this sorted slice with a comparator function.</p>
<p>The comparator function should implement an order consistent
with the sort order of the underlying slice, returning an
order code that indicates whether its argument is <code>Less</code>,
<code>Equal</code> or <code>Greater</code> the desired target.</p>
<p>If the value is found then <a href="../../std/result/enum.Result.html#Ok.v" title="`Result::Ok`"><code>Result::Ok</code></a> is returned, containing the
index of the matching element. If there are multiple matches, then any
one of the matches could be returned. If the value is not found then
<a href="../../std/result/enum.Result.html#Err.v" title="`Result::Err`"><code>Result::Err</code></a> is returned, containing the index where a matching
element could be inserted while maintaining sorted order.</p>
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
<p>Looks up a series of four elements. The first is found, with a
uniquely determined position; the second and third are not
found; the fourth could match any position in <code>[1, 4]</code>.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> [<span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">13</span>, <span class="number">21</span>, <span class="number">34</span>, <span class="number">55</span>];

<span class="kw">let</span> <span class="ident">seek</span> <span class="op">=</span> <span class="number">13</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search_by</span>(<span class="op">|</span><span class="ident">probe</span><span class="op">|</span> <span class="ident">probe</span>.<span class="ident">cmp</span>(<span class="kw-2">&amp;</span><span class="ident">seek</span>)), <span class="prelude-val">Ok</span>(<span class="number">9</span>));
<span class="kw">let</span> <span class="ident">seek</span> <span class="op">=</span> <span class="number">4</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search_by</span>(<span class="op">|</span><span class="ident">probe</span><span class="op">|</span> <span class="ident">probe</span>.<span class="ident">cmp</span>(<span class="kw-2">&amp;</span><span class="ident">seek</span>)), <span class="prelude-val">Err</span>(<span class="number">7</span>));
<span class="kw">let</span> <span class="ident">seek</span> <span class="op">=</span> <span class="number">100</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search_by</span>(<span class="op">|</span><span class="ident">probe</span><span class="op">|</span> <span class="ident">probe</span>.<span class="ident">cmp</span>(<span class="kw-2">&amp;</span><span class="ident">seek</span>)), <span class="prelude-val">Err</span>(<span class="number">13</span>));
<span class="kw">let</span> <span class="ident">seek</span> <span class="op">=</span> <span class="number">1</span>;
<span class="kw">let</span> <span class="ident">r</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">binary_search_by</span>(<span class="op">|</span><span class="ident">probe</span><span class="op">|</span> <span class="ident">probe</span>.<span class="ident">cmp</span>(<span class="kw-2">&amp;</span><span class="ident">seek</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="kw">match</span> <span class="ident">r</span> { <span class="prelude-val">Ok</span>(<span class="number">1</span>..=<span class="number">4</span>) <span class="op">=&gt;</span> <span class="bool-val">true</span>, <span class="kw">_</span> <span class="op">=&gt;</span> <span class="bool-val">false</span>, });<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20s%20%3D%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%202%2C%203%2C%205%2C%208%2C%2013%2C%2021%2C%2034%2C%2055%5D%3B%0A%0Alet%20seek%20%3D%2013%3B%0Aassert_eq!(s.binary_search_by(%7Cprobe%7C%20probe.cmp(%26seek))%2C%20Ok(9))%3B%0Alet%20seek%20%3D%204%3B%0Aassert_eq!(s.binary_search_by(%7Cprobe%7C%20probe.cmp(%26seek))%2C%20Err(7))%3B%0Alet%20seek%20%3D%20100%3B%0Aassert_eq!(s.binary_search_by(%7Cprobe%7C%20probe.cmp(%26seek))%2C%20Err(13))%3B%0Alet%20seek%20%3D%201%3B%0Alet%20r%20%3D%20s.binary_search_by(%7Cprobe%7C%20probe.cmp(%26seek))%3B%0Aassert!(match%20r%20%7B%20Ok(1..%3D4)%20%3D%3E%20true%2C%20_%20%3D%3E%20false%2C%20%7D)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.binary_search_by_key' class="method"><code id='binary_search_by_key.v'>pub fn <a href='#method.binary_search_by_key' class='fnname'>binary_search_by_key</a>&lt;'a, B, F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;'a self, <br>&nbsp;&nbsp;&nbsp;&nbsp;b: <a class="primitive" href="../primitive.reference.html">&amp;</a>B, <br>&nbsp;&nbsp;&nbsp;&nbsp;f: F<br>) -&gt; <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a>&lt;<a class="primitive" href="../primitive.usize.html">usize</a>, <a class="primitive" href="../primitive.usize.html">usize</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../../std/cmp/trait.Ord.html" title="trait std::cmp::Ord">Ord</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;'a </a>T) -&gt; B,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.10.0'>1.10.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#1456-1461' title='goto source code'>[src]</a></h4><div class='docblock'><p>Binary searches this sorted slice with a key extraction function.</p>
<p>Assumes that the slice is sorted by the key, for instance with
<a href="#method.sort_by_key"><code>sort_by_key</code></a> using the same key extraction function.</p>
<p>If the value is found then <a href="../../std/result/enum.Result.html#Ok.v" title="`Result::Ok`"><code>Result::Ok</code></a> is returned, containing the
index of the matching element. If there are multiple matches, then any
one of the matches could be returned. If the value is not found then
<a href="../../std/result/enum.Result.html#Err.v" title="`Result::Err`"><code>Result::Err</code></a> is returned, containing the index where a matching
element could be inserted while maintaining sorted order.</p>
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
<p>Looks up a series of four elements in a slice of pairs sorted by
their second elements. The first is found, with a uniquely
determined position; the second and third are not found; the
fourth could match any position in <code>[1, 4]</code>.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> [(<span class="number">0</span>, <span class="number">0</span>), (<span class="number">2</span>, <span class="number">1</span>), (<span class="number">4</span>, <span class="number">1</span>), (<span class="number">5</span>, <span class="number">1</span>), (<span class="number">3</span>, <span class="number">1</span>),
         (<span class="number">1</span>, <span class="number">2</span>), (<span class="number">2</span>, <span class="number">3</span>), (<span class="number">4</span>, <span class="number">5</span>), (<span class="number">5</span>, <span class="number">8</span>), (<span class="number">3</span>, <span class="number">13</span>),
         (<span class="number">1</span>, <span class="number">21</span>), (<span class="number">2</span>, <span class="number">34</span>), (<span class="number">4</span>, <span class="number">55</span>)];

<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search_by_key</span>(<span class="kw-2">&amp;</span><span class="number">13</span>, <span class="op">|</span><span class="kw-2">&amp;</span>(<span class="ident">a</span>,<span class="ident">b</span>)<span class="op">|</span> <span class="ident">b</span>),  <span class="prelude-val">Ok</span>(<span class="number">9</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search_by_key</span>(<span class="kw-2">&amp;</span><span class="number">4</span>, <span class="op">|</span><span class="kw-2">&amp;</span>(<span class="ident">a</span>,<span class="ident">b</span>)<span class="op">|</span> <span class="ident">b</span>),   <span class="prelude-val">Err</span>(<span class="number">7</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>.<span class="ident">binary_search_by_key</span>(<span class="kw-2">&amp;</span><span class="number">100</span>, <span class="op">|</span><span class="kw-2">&amp;</span>(<span class="ident">a</span>,<span class="ident">b</span>)<span class="op">|</span> <span class="ident">b</span>), <span class="prelude-val">Err</span>(<span class="number">13</span>));
<span class="kw">let</span> <span class="ident">r</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">binary_search_by_key</span>(<span class="kw-2">&amp;</span><span class="number">1</span>, <span class="op">|</span><span class="kw-2">&amp;</span>(<span class="ident">a</span>,<span class="ident">b</span>)<span class="op">|</span> <span class="ident">b</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="kw">match</span> <span class="ident">r</span> { <span class="prelude-val">Ok</span>(<span class="number">1</span>..=<span class="number">4</span>) <span class="op">=&gt;</span> <span class="bool-val">true</span>, <span class="kw">_</span> <span class="op">=&gt;</span> <span class="bool-val">false</span>, });<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20s%20%3D%20%5B(0%2C%200)%2C%20(2%2C%201)%2C%20(4%2C%201)%2C%20(5%2C%201)%2C%20(3%2C%201)%2C%0A%20%20%20%20%20%20%20%20%20(1%2C%202)%2C%20(2%2C%203)%2C%20(4%2C%205)%2C%20(5%2C%208)%2C%20(3%2C%2013)%2C%0A%20%20%20%20%20%20%20%20%20(1%2C%2021)%2C%20(2%2C%2034)%2C%20(4%2C%2055)%5D%3B%0A%0Aassert_eq!(s.binary_search_by_key(%2613%2C%20%7C%26(a%2Cb)%7C%20b)%2C%20%20Ok(9))%3B%0Aassert_eq!(s.binary_search_by_key(%264%2C%20%7C%26(a%2Cb)%7C%20b)%2C%20%20%20Err(7))%3B%0Aassert_eq!(s.binary_search_by_key(%26100%2C%20%7C%26(a%2Cb)%7C%20b)%2C%20Err(13))%3B%0Alet%20r%20%3D%20s.binary_search_by_key(%261%2C%20%7C%26(a%2Cb)%7C%20b)%3B%0Aassert!(match%20r%20%7B%20Ok(1..%3D4)%20%3D%3E%20true%2C%20_%20%3D%3E%20false%2C%20%7D)%3B%0A%7D">Run</a></pre></div>
</div><h4 id='method.align_to' class="method"><code id='align_to.v'>pub unsafe fn <a href='#method.align_to' class='fnname'>align_to</a>&lt;U&gt;(&amp;self) -&gt; <a class="primitive" href="../primitive.tuple.html">(</a><a class="primitive" href="../primitive.slice.html">&amp;[T]</a>, <a class="primitive" href="../primitive.slice.html">&amp;[U]</a>, <a class="primitive" href="../primitive.slice.html">&amp;[T]</a><a class="primitive" href="../primitive.tuple.html">)</a></code><div class='since' title='Stable since Rust version 1.30.0'>1.30.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#2327-2348' title='goto source code'>[src]</a></h4><div class='docblock'><p>Transmute the slice to a slice of another type, ensuring alignment of the types is
maintained.</p>
<p>This method splits the slice into three distinct slices: prefix, correctly aligned middle
slice of a new type, and the suffix slice. The method does a best effort to make the
middle slice the greatest length possible for a given type and input slice, but only
your algorithm's performance should depend on that, not its correctness.</p>
<p>This method has no purpose when either input element <code>T</code> or output element <code>U</code> are
zero-sized and will return the original slice without splitting anything.</p>
<h1 id="safety" class="section-header"><a href="#safety">Safety</a></h1>
<p>This method is essentially a <code>transmute</code> with respect to the elements in the returned
middle slice, so all the usual caveats pertaining to <code>transmute::&lt;T, U&gt;</code> also apply here.</p>
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
<p>Basic usage:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">unsafe</span> {
    <span class="kw">let</span> <span class="ident">bytes</span>: [<span class="ident">u8</span>; <span class="number">7</span>] <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>];
    <span class="kw">let</span> (<span class="ident">prefix</span>, <span class="ident">shorts</span>, <span class="ident">suffix</span>) <span class="op">=</span> <span class="ident">bytes</span>.<span class="ident">align_to</span>::<span class="op">&lt;</span><span class="ident">u16</span><span class="op">&gt;</span>();
    <span class="comment">// less_efficient_algorithm_for_bytes(prefix);</span>
    <span class="comment">// more_efficient_algorithm_for_aligned_shorts(shorts);</span>
    <span class="comment">// less_efficient_algorithm_for_bytes(suffix);</span>
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Aunsafe%20%7B%0A%20%20%20%20let%20bytes%3A%20%5Bu8%3B%207%5D%20%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%2C%207%5D%3B%0A%20%20%20%20let%20(prefix%2C%20shorts%2C%20suffix)%20%3D%20bytes.align_to%3A%3A%3Cu16%3E()%3B%0A%20%20%20%20%2F%2F%20less_efficient_algorithm_for_bytes(prefix)%3B%0A%20%20%20%20%2F%2F%20more_efficient_algorithm_for_aligned_shorts(shorts)%3B%0A%20%20%20%20%2F%2F%20less_efficient_algorithm_for_bytes(suffix)%3B%0A%7D%0A%7D">Run</a></pre></div>
</div><h4 id='method.is_sorted' class="method"><code id='is_sorted.v'>pub fn <a href='#method.is_sorted' class='fnname'>is_sorted</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/cmp/trait.PartialOrd.html" title="trait std::cmp::PartialOrd">PartialOrd</a>&lt;T&gt;,&nbsp;</span></code><a class='srclink' href='../../src/core/slice/mod.rs.html#2427-2432' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>is_sorted</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/53485">#53485</a>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Checks if the elements of this slice are sorted.</p>
<p>That is, for each element <code>a</code> and its following element <code>b</code>, <code>a &lt;= b</code> must hold. If the
slice yields exactly zero or one element, <code>true</code> is returned.</p>
<p>Note that if <code>Self::Item</code> is only <code>PartialOrd</code>, but not <code>Ord</code>, the above definition
implies that this function returns <code>false</code> if any two consecutive items are not
comparable.</p>
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">is_sorted</span>)]</span>
<span class="kw">let</span> <span class="ident">empty</span>: [<span class="ident">i32</span>; <span class="number">0</span>] <span class="op">=</span> [];

<span class="macro">assert</span><span class="macro">!</span>([<span class="number">1</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">9</span>].<span class="ident">is_sorted</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">4</span>].<span class="ident">is_sorted</span>());
<span class="macro">assert</span><span class="macro">!</span>([<span class="number">0</span>].<span class="ident">is_sorted</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">empty</span>.<span class="ident">is_sorted</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span>[<span class="number">0.0</span>, <span class="number">1.0</span>, <span class="ident">std</span>::<span class="ident">f32</span>::<span class="ident">NAN</span>].<span class="ident">is_sorted</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(is_sorted)%5D%0Afn%20main()%20%7B%0Alet%20empty%3A%20%5Bi32%3B%200%5D%20%3D%20%5B%5D%3B%0A%0Aassert!(%5B1%2C%202%2C%202%2C%209%5D.is_sorted())%3B%0Aassert!(!%5B1%2C%203%2C%202%2C%204%5D.is_sorted())%3B%0Aassert!(%5B0%5D.is_sorted())%3B%0Aassert!(empty.is_sorted())%3B%0Aassert!(!%5B0.0%2C%201.0%2C%20std%3A%3Af32%3A%3ANAN%5D.is_sorted())%3B%0A%7D&amp;version=nightly">Run</a></pre></div>
</div><h4 id='method.is_sorted_by' class="method"><code id='is_sorted_by.v'>pub fn <a href='#method.is_sorted_by' class='fnname'>is_sorted_by</a>&lt;F&gt;(&amp;self, compare: F) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T, <a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;<a class="enum" href="../../std/cmp/enum.Ordering.html" title="enum std::cmp::Ordering">Ordering</a>&gt;,&nbsp;</span></code><a class='srclink' href='../../src/core/slice/mod.rs.html#2442-2447' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>is_sorted</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/53485">#53485</a>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Checks if the elements of this slice are sorted using the given comparator function.</p>
<p>Instead of using <code>PartialOrd::partial_cmp</code>, this function uses the given <code>compare</code>
function to determine the ordering of two elements. Apart from that, it's equivalent to
<a href="#method.is_sorted"><code>is_sorted</code></a>; see its documentation for more information.</p>
</div><h4 id='method.is_sorted_by_key' class="method"><code id='is_sorted_by_key.v'>pub fn <a href='#method.is_sorted_by_key' class='fnname'>is_sorted_by_key</a>&lt;F, K&gt;(&amp;self, f: F) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/ops/trait.FnMut.html" title="trait std::ops::FnMut">FnMut</a>(<a class="primitive" href="../primitive.reference.html">&amp;</a>T) -&gt; K,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="../../std/cmp/trait.PartialOrd.html" title="trait std::cmp::PartialOrd">PartialOrd</a>&lt;K&gt;,&nbsp;</span></code><a class='srclink' href='../../src/core/slice/mod.rs.html#2467-2473' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>is_sorted</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/53485">#53485</a>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Checks if the elements of this slice are sorted using the given key extraction function.</p>
<p>Instead of comparing the slice's elements directly, this function compares the keys of the
elements, as determined by <code>f</code>. Apart from that, it's equivalent to <a href="#method.is_sorted"><code>is_sorted</code></a>; see its
documentation for more information.</p>
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">is_sorted</span>)]</span>

<span class="macro">assert</span><span class="macro">!</span>([<span class="string">&quot;c&quot;</span>, <span class="string">&quot;bb&quot;</span>, <span class="string">&quot;aaa&quot;</span>].<span class="ident">is_sorted_by_key</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">len</span>()));
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span>[<span class="op">-</span><span class="number">2i32</span>, <span class="op">-</span><span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>].<span class="ident">is_sorted_by_key</span>(<span class="op">|</span><span class="ident">n</span><span class="op">|</span> <span class="ident">n</span>.<span class="ident">abs</span>()));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(is_sorted)%5D%0A%0Afn%20main()%20%7B%0Aassert!(%5B%22c%22%2C%20%22bb%22%2C%20%22aaa%22%5D.is_sorted_by_key(%7Cs%7C%20s.len()))%3B%0Aassert!(!%5B-2i32%2C%20-1%2C%200%2C%203%5D.is_sorted_by_key(%7Cn%7C%20n.abs()))%3B%0A%7D&amp;version=nightly">Run</a></pre></div>
</div></div><div class='impl-items'><h4 id='method.is_ascii' class="method"><code id='is_ascii.v'>pub fn <a href='#method.is_ascii' class='fnname'>is_ascii</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.23.0'>1.23.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#2482-2484' title='goto source code'>[src]</a></h4><div class='docblock'><p>Checks if all bytes in this slice are within the ASCII range.</p>
</div><h4 id='method.eq_ignore_ascii_case' class="method"><code id='eq_ignore_ascii_case.v'>pub fn <a href='#method.eq_ignore_ascii_case' class='fnname'>eq_ignore_ascii_case</a>(&amp;self, other: <a class="primitive" href="../primitive.slice.html">&amp;[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -&gt; <a class="primitive" href="../primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.23.0'>1.23.0</div><a class='srclink' href='../../src/core/slice/mod.rs.html#2492-2497' title='goto source code'>[src]</a></h4><div class='docblock'><p>Checks that two slices are an ASCII case-insensitive match.</p>
<p>Same as <code>to_ascii_lowercase(a) == to_ascii_lowercase(b)</code>,
but without allocating and copying temporaries.</p>
</div></div><div class='impl-items'><h4 id='method.to_vec' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></code></div></div><code id='to_vec.v'>pub fn <a href='#method.to_vec' class='fnname'>to_vec</a>(&amp;self) -&gt; <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/alloc/slice.rs.html#376-381' title='goto source code'>[src]</a></h4><div class='docblock'><p>Copies <code>self</code> into a new <code>Vec</code>.</p>
<h1 id="examples-29" class="section-header"><a href="#examples-29">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>];
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">to_vec</span>();
<span class="comment">// Here, `s` and `x` can be modified independently.</span><a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Alet%20s%20%3D%20%5B10%2C%2040%2C%2030%5D%3B%0Alet%20x%20%3D%20s.to_vec()%3B%0A%2F%2F%20Here%2C%20%60s%60%20and%20%60x%60%20can%20be%20modified%20independently.%0A%7D">Run</a></pre></div>
</div><h4 id='method.repeat' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></code></div></div><code id='repeat.v'>pub fn <a href='#method.repeat' class='fnname'>repeat</a>(&amp;self, n: <a class="primitive" href="../primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/marker/trait.Copy.html" title="trait std::marker::Copy">Copy</a>,&nbsp;</span></code><a class='srclink' href='../../src/alloc/slice.rs.html#434-487' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>repeat_generic_slice</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/48784">#48784</a>)</summary><p>it's on str, why not on slice?</p>
</details></div></div><div class='docblock'><p>Creates a vector by repeating a slice <code>n</code> times.</p>
<h1 id="panics-7" class="section-header"><a href="#panics-7">Panics</a></h1>
<p>This function will panic if the capacity would overflow.</p>
<h1 id="examples-30" class="section-header"><a href="#examples-30">Examples</a></h1>
<p>Basic usage:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">repeat_generic_slice</span>)]</span>

<span class="kw">fn</span> <span class="ident">main</span>() {
    <span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">1</span>, <span class="number">2</span>].<span class="ident">repeat</span>(<span class="number">3</span>), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">1</span>, <span class="number">2</span>]);
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(repeat_generic_slice)%5D%0A%0Afn%20main()%20%7B%0A%20%20%20%20assert_eq!(%5B1%2C%202%5D.repeat(3)%2C%20vec!%5B1%2C%202%2C%201%2C%202%2C%201%2C%202%5D)%3B%0A%7D&amp;version=nightly">Run</a></pre></div>
<p>A panic upon overflow:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">repeat_generic_slice</span>)]</span>
<span class="kw">fn</span> <span class="ident">main</span>() {
    <span class="comment">// this will panic at runtime</span>
    <span class="string">b&quot;0123456789abcdef&quot;</span>.<span class="ident">repeat</span>(<span class="ident">usize</span>::<span class="ident">max_value</span>());
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(repeat_generic_slice)%5D%0Afn%20main()%20%7B%0A%20%20%20%20%2F%2F%20this%20will%20panic%20at%20runtime%0A%20%20%20%20b%220123456789abcdef%22.repeat(usize%3A%3Amax_value())%3B%0A%7D&amp;version=nightly">Run</a></pre></div>
</div></div><div class='impl-items'><h4 id='method.to_ascii_uppercase' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></code></div></div><code id='to_ascii_uppercase.v'>pub fn <a href='#method.to_ascii_uppercase' class='fnname'>to_ascii_uppercase</a>(&amp;self) -&gt; <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</code><div class='since' title='Stable since Rust version 1.23.0'>1.23.0</div><a class='srclink' href='../../src/alloc/slice.rs.html#504-508' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a vector containing a copy of this slice where each byte
is mapped to its ASCII upper case equivalent.</p>
<p>ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
but non-ASCII letters are unchanged.</p>
<p>To uppercase the value in-place, use <a href="#method.make_ascii_uppercase"><code>make_ascii_uppercase</code></a>.</p>
</div><h4 id='method.to_ascii_lowercase' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</span></code></div></div><code id='to_ascii_lowercase.v'>pub fn <a href='#method.to_ascii_lowercase' class='fnname'>to_ascii_lowercase</a>(&amp;self) -&gt; <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a>&lt;<a class="primitive" href="../primitive.u8.html">u8</a>&gt;</code><div class='since' title='Stable since Rust version 1.23.0'>1.23.0</div><a class='srclink' href='../../src/alloc/slice.rs.html#521-525' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a vector containing a copy of this slice where each byte
is mapped to its ASCII lower case equivalent.</p>
<p>ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
but non-ASCII letters are unchanged.</p>
<p>To lowercase the value in-place, use <a href="#method.make_ascii_lowercase"><code>make_ascii_lowercase</code></a>.</p>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Deref' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="../../std/ops/trait.Deref.html" title="trait std::ops::Deref">Deref</a> for <a class="struct" href="../../std/io/struct.IoVec.html" title="struct std::io::IoVec">IoVec</a>&lt;'a&gt;</code><a href='#impl-Deref' class='anchor'></a><a class='srclink' href='../../src/std/io/mod.rs.html#986-993' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Target' class="type"><code id='Target.t'>type <a href='../../std/ops/trait.Deref.html#associatedtype.Target' class="type">Target</a> = <a class="primitive" href="../primitive.slice.html">[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></code></h4><div class='docblock'><p>The resulting type after dereferencing.</p>
</div><h4 id='method.deref' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.slice.html">&amp;'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.slice.html">&amp;'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></h3><code class="content"><span class="where fmt-newline">impl&lt;'_&gt; <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.slice.html">&amp;'_ [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span><span class="where fmt-newline">impl&lt;'_&gt; <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.slice.html">&amp;'_ mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></span></code></div></div><code id='deref.v'>fn <a href='../../std/ops/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.slice.html">&amp;[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a></code><a class='srclink' href='../../src/std/io/mod.rs.html#990-992' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Dereferences the value.</p>
</div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="struct" href="../../std/io/struct.IoVec.html" title="struct std::io::IoVec">IoVec</a>&lt;'a&gt;</code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../src/std/io/mod.rs.html#966-970' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='../../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, fmt: &amp;mut <a class="struct" href="../../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="../../std/fmt/type.Result.html" title="type std::fmt::Result">Result</a></code><a class='srclink' href='../../src/std/io/mod.rs.html#967-969' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="../../std/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Send' class='impl'><code class='in-band'>impl&lt;'a&gt; !<a class="trait" href="../../std/marker/trait.Send.html" title="trait std::marker::Send">Send</a> for <a class="struct" href="../../std/io/struct.IoVec.html" title="struct std::io::IoVec">IoVec</a>&lt;'a&gt;</code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><code class='in-band'>impl&lt;'a&gt; !<a class="trait" href="../../std/marker/trait.Sync.html" title="trait std::marker::Sync">Sync</a> for <a class="struct" href="../../std/io/struct.IoVec.html" title="struct std::io::IoVec">IoVec</a>&lt;'a&gt;</code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-TryFrom' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryFrom' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#565-571' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='../../std/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="../../std/convert/enum.Infallible.html" title="enum std::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='../../std/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='../../src/core/convert.rs.html#568-570' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-From' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a> for T</code><a href='#impl-From' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#546-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code><a class='srclink' href='../../src/core/convert.rs.html#547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryInto' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="../../std/convert/trait.TryInto.html" title="trait std::convert::TryInto">TryInto</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#553-560' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='../../std/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='../../std/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='../../src/core/convert.rs.html#557-559' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Into' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#537-542' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='../../std/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code><a class='srclink' href='../../src/core/convert.rs.html#539-541' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Borrow' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="../../std/borrow/trait.Borrow.html" title="trait std::borrow::Borrow">Borrow</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow' class='anchor'></a><a class='srclink' href='../../src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>F</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl&lt;'_, F&gt; <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>F <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = &lt;F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>&gt;::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl&lt;'_, I&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>I <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = &lt;I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>&gt;::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl&lt;R:&nbsp;<a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_&gt; <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>R</span><span class="where fmt-newline">impl&lt;W:&nbsp;<a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_&gt; <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>W</span></code></div></div><code id='borrow.v'>fn <a href='../../std/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.reference.html">&amp;</a>T</code><a class='srclink' href='../../src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="../../std/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-BorrowMut' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="../../std/borrow/trait.BorrowMut.html" title="trait std::borrow::BorrowMut">BorrowMut</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut' class='anchor'></a><a class='srclink' href='../../src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>F</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl&lt;'_, F&gt; <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>F <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = &lt;F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>&gt;::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl&lt;'_, I&gt; <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>I <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></span><span class="where fmt-newline">    type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = &lt;I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>&gt;::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl&lt;R:&nbsp;<a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_&gt; <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>R</span><span class="where fmt-newline">impl&lt;W:&nbsp;<a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_&gt; <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.reference.html">&amp;'_ mut </a>W</span></code></div></div><code id='borrow_mut.v'>fn <a href='../../std/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="../primitive.reference.html">&amp;mut </a>T</code><a class='srclink' href='../../src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="../../std/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="../../std/any/trait.Any.html" title="trait std::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='../../src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='../../std/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&amp;self) -&gt; <a class="struct" href="../../std/any/struct.TypeId.html" title="struct std::any::TypeId">TypeId</a></code><a class='srclink' href='../../src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="../../std/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "std";</script><script src="../../aliases.js"></script><script src="../../main1.35.0.js"></script><script defer src="../../search-index.js"></script></body></html>