| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A cheaply cloneable and sliceable chunk of contiguous memory."><meta name="keywords" content="rust, rustlang, rust-lang, Bytes"><title>Bytes in bytes - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../bytes/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../bytes/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Bytes</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.clear">clear</a></li><li><a href="#method.copy_from_slice">copy_from_slice</a></li><li><a href="#method.from_static">from_static</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.len">len</a></li><li><a href="#method.new">new</a></li><li><a href="#method.slice">slice</a></li><li><a href="#method.slice_ref">slice_ref</a></li><li><a href="#method.split_off">split_off</a></li><li><a href="#method.split_to">split_to</a></li><li><a href="#method.truncate">truncate</a></li></ul><h3><a href="#deref-methods-%5Bu8%5D">Methods from Deref<Target=[u8]></a></h3><ul class="block"><li><a href="#method.align_to">align_to</a></li><li><a href="#method.array_chunks">array_chunks</a></li><li><a href="#method.array_windows">array_windows</a></li><li><a href="#method.as_chunks">as_chunks</a></li><li><a href="#method.as_chunks_unchecked">as_chunks_unchecked</a></li><li><a href="#method.as_ptr">as_ptr</a></li><li><a href="#method.as_ptr_range">as_ptr_range</a></li><li><a href="#method.as_rchunks">as_rchunks</a></li><li><a href="#method.as_simd">as_simd</a></li><li><a href="#method.binary_search">binary_search</a></li><li><a href="#method.binary_search_by">binary_search_by</a></li><li><a href="#method.binary_search_by_key">binary_search_by_key</a></li><li><a href="#method.chunks">chunks</a></li><li><a href="#method.chunks_exact">chunks_exact</a></li><li><a href="#method.concat">concat</a></li><li><a href="#method.connect">connect</a></li><li><a href="#method.contains">contains</a></li><li><a href="#method.ends_with">ends_with</a></li><li><a href="#method.eq_ignore_ascii_case">eq_ignore_ascii_case</a></li><li><a href="#method.escape_ascii">escape_ascii</a></li><li><a href="#method.first">first</a></li><li><a href="#method.flatten">flatten</a></li><li><a href="#method.get">get</a></li><li><a href="#method.get_unchecked">get_unchecked</a></li><li><a href="#method.group_by">group_by</a></li><li><a href="#method.is_ascii">is_ascii</a></li><li><a href="#method.is_empty-1">is_empty</a></li><li><a href="#method.is_sorted">is_sorted</a></li><li><a href="#method.is_sorted_by">is_sorted_by</a></li><li><a href="#method.is_sorted_by_key">is_sorted_by_key</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.join">join</a></li><li><a href="#method.last">last</a></li><li><a href="#method.len-1">len</a></li><li><a href="#method.partition_point">partition_point</a></li><li><a href="#method.rchunks">rchunks</a></li><li><a href="#method.rchunks_exact">rchunks_exact</a></li><li><a href="#method.repeat">repeat</a></li><li><a href="#method.rsplit">rsplit</a></li><li><a href="#method.rsplit_array_ref">rsplit_array_ref</a></li><li><a href="#method.rsplitn">rsplitn</a></li><li><a href="#method.split">split</a></li><li><a href="#method.split_array_ref">split_array_ref</a></li><li><a href="#method.split_at">split_at</a></li><li><a href="#method.split_at_unchecked">split_at_unchecked</a></li><li><a href="#method.split_first">split_first</a></li><li><a href="#method.split_inclusive">split_inclusive</a></li><li><a href="#method.split_last">split_last</a></li><li><a href="#method.splitn">splitn</a></li><li><a href="#method.starts_with">starts_with</a></li><li><a href="#method.strip_prefix">strip_prefix</a></li><li><a href="#method.strip_suffix">strip_suffix</a></li><li><a href="#method.to_ascii_lowercase">to_ascii_lowercase</a></li><li><a href="#method.to_ascii_uppercase">to_ascii_uppercase</a></li><li><a href="#method.to_vec">to_vec</a></li><li><a href="#method.to_vec_in">to_vec_in</a></li><li><a href="#method.trim_ascii">trim_ascii</a></li><li><a href="#method.trim_ascii_end">trim_ascii_end</a></li><li><a href="#method.trim_ascii_start">trim_ascii_start</a></li><li><a href="#method.windows">windows</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-AsRef%3C%5Bu8%5D%3E-for-Bytes">AsRef<[u8]></a></li><li><a href="#impl-Borrow%3C%5Bu8%5D%3E-for-Bytes">Borrow<[u8]></a></li><li><a href="#impl-Buf-for-Bytes">Buf</a></li><li><a href="#impl-Clone-for-Bytes">Clone</a></li><li><a href="#impl-Debug-for-Bytes">Debug</a></li><li><a href="#impl-Default-for-Bytes">Default</a></li><li><a href="#impl-Deref-for-Bytes">Deref</a></li><li><a href="#impl-Drop-for-Bytes">Drop</a></li><li><a href="#impl-Eq-for-Bytes">Eq</a></li><li><a href="#impl-Extend%3CBytes%3E-for-BytesMut">Extend<Bytes></a></li><li><a href="#impl-From%3C%26%27static%20%5Bu8%5D%3E-for-Bytes">From<&'static [u8]></a></li><li><a href="#impl-From%3C%26%27static%20str%3E-for-Bytes">From<&'static str></a></li><li><a href="#impl-From%3CBox%3C%5Bu8%5D%2C%20Global%3E%3E-for-Bytes">From<Box<[u8], Global>></a></li><li><a href="#impl-From%3CBytes%3E-for-Vec%3Cu8%3E">From<Bytes></a></li><li><a href="#impl-From%3CBytesMut%3E-for-Bytes">From<BytesMut></a></li><li><a href="#impl-From%3CString%3E-for-Bytes">From<String></a></li><li><a href="#impl-From%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes">From<Vec<u8, Global>></a></li><li><a href="#impl-FromIterator%3Cu8%3E-for-Bytes">FromIterator<u8></a></li><li><a href="#impl-Hash-for-Bytes">Hash</a></li><li><a href="#impl-IntoIterator-for-%26%27a%20Bytes">IntoIterator</a></li><li><a href="#impl-IntoIterator-for-Bytes">IntoIterator</a></li><li><a href="#impl-LowerHex-for-Bytes">LowerHex</a></li><li><a href="#impl-Ord-for-Bytes">Ord</a></li><li><a href="#impl-PartialEq%3C%26%27a%20T%3E-for-Bytes">PartialEq<&'a T></a></li><li><a href="#impl-PartialEq%3C%5Bu8%5D%3E-for-Bytes">PartialEq<[u8]></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-%26%5Bu8%5D">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-%26str">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-%5Bu8%5D">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-Bytes">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-BytesMut">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-String">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-Vec%3Cu8%3E">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytes%3E-for-str">PartialEq<Bytes></a></li><li><a href="#impl-PartialEq%3CBytesMut%3E-for-Bytes">PartialEq<BytesMut></a></li><li><a href="#impl-PartialEq%3CString%3E-for-Bytes">PartialEq<String></a></li><li><a href="#impl-PartialEq%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes">PartialEq<Vec<u8, Global>></a></li><li><a href="#impl-PartialEq%3Cstr%3E-for-Bytes">PartialEq<str></a></li><li><a href="#impl-PartialOrd%3C%26%27a%20T%3E-for-Bytes">PartialOrd<&'a T></a></li><li><a href="#impl-PartialOrd%3C%5Bu8%5D%3E-for-Bytes">PartialOrd<[u8]></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-%26%5Bu8%5D">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-%26str">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-%5Bu8%5D">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-Bytes">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-String">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-Vec%3Cu8%3E">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CBytes%3E-for-str">PartialOrd<Bytes></a></li><li><a href="#impl-PartialOrd%3CString%3E-for-Bytes">PartialOrd<String></a></li><li><a href="#impl-PartialOrd%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes">PartialOrd<Vec<u8, Global>></a></li><li><a href="#impl-PartialOrd%3Cstr%3E-for-Bytes">PartialOrd<str></a></li><li><a href="#impl-Send-for-Bytes">Send</a></li><li><a href="#impl-Sync-for-Bytes">Sync</a></li><li><a href="#impl-UpperHex-for-Bytes">UpperHex</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Bytes">RefUnwindSafe</a></li><li><a href="#impl-Unpin-for-Bytes">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Bytes">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Bytes">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Bytes">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Bytes">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Bytes">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Bytes">Into<U></a></li><li><a href="#impl-ToOwned-for-Bytes">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Bytes">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Bytes">TryInto<U></a></li></ul></section><h2><a href="index.html">In bytes</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">bytes</a>::<wbr><a class="struct" href="#">Bytes</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/bytes/bytes.rs.html#100-106">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Bytes { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A cheaply cloneable and sliceable chunk of contiguous memory.</p> |
| <p><code>Bytes</code> is an efficient container for storing and operating on contiguous |
| slices of memory. It is intended for use primarily in networking code, but |
| could have applications elsewhere as well.</p> |
| <p><code>Bytes</code> values facilitate zero-copy network programming by allowing multiple |
| <code>Bytes</code> objects to point to the same underlying memory.</p> |
| <p><code>Bytes</code> does not have a single implementation. It is an interface, whose |
| exact behavior is implemented through dynamic dispatch in several underlying |
| implementations of <code>Bytes</code>.</p> |
| <p>All <code>Bytes</code> implementations must fulfill the following requirements:</p> |
| <ul> |
| <li>They are cheaply cloneable and thereby shareable between an unlimited amount |
| of components, for example by modifying a reference count.</li> |
| <li>Instances can be sliced to refer to a subset of the original buffer.</li> |
| </ul> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>mem = Bytes::from(<span class="string">"Hello world"</span>); |
| <span class="kw">let </span>a = mem.slice(<span class="number">0</span>..<span class="number">5</span>); |
| |
| <span class="macro">assert_eq!</span>(a, <span class="string">"Hello"</span>); |
| |
| <span class="kw">let </span>b = mem.split_to(<span class="number">6</span>); |
| |
| <span class="macro">assert_eq!</span>(mem, <span class="string">"world"</span>); |
| <span class="macro">assert_eq!</span>(b, <span class="string">"Hello "</span>);</code></pre></div> |
| <h2 id="memory-layout"><a href="#memory-layout">Memory layout</a></h2> |
| <p>The <code>Bytes</code> struct itself is fairly small, limited to 4 <code>usize</code> fields used |
| to track information about which segment of the underlying memory the |
| <code>Bytes</code> handle has access to.</p> |
| <p><code>Bytes</code> keeps both a pointer to the shared state containing the full memory |
| slice and a pointer to the start of the region visible by the handle. |
| <code>Bytes</code> also tracks the length of its view into the memory.</p> |
| <h2 id="sharing"><a href="#sharing">Sharing</a></h2> |
| <p><code>Bytes</code> contains a vtable, which allows implementations of <code>Bytes</code> to define |
| how sharing/cloning is implemented in detail. |
| When <code>Bytes::clone()</code> is called, <code>Bytes</code> will call the vtable function for |
| cloning the backing storage in order to share it behind between multiple |
| <code>Bytes</code> instances.</p> |
| <p>For <code>Bytes</code> implementations which refer to constant memory (e.g. created |
| via <code>Bytes::from_static()</code>) the cloning implementation will be a no-op.</p> |
| <p>For <code>Bytes</code> implementations which point to a reference counted shared storage |
| (e.g. an <code>Arc<[u8]></code>), sharing will be implemented by increasing the |
| reference count.</p> |
| <p>Due to this mechanism, multiple <code>Bytes</code> instances may point to the same |
| shared memory region. |
| Each <code>Bytes</code> instance can point to different sections within that |
| memory region, and <code>Bytes</code> instances may or may not have overlapping views |
| into the memory.</p> |
| <p>The following diagram visualizes a scenario where 2 <code>Bytes</code> instances make |
| use of an <code>Arc</code>-based backing storage, and provide access to different views:</p> |
| <div class="example-wrap"><pre class="language-text"><code> |
| Arc ptrs ┌─────────┐ |
| ________________________ / │ Bytes 2 │ |
| / └─────────┘ |
| / ┌───────────┐ | | |
| |_________/ │ Bytes 1 │ | | |
| | └───────────┘ | | |
| | | | ___/ data | tail |
| | data | tail |/ | |
| v v v v |
| ┌─────┬─────┬───────────┬───────────────┬─────┐ |
| │ Arc │ │ │ │ │ |
| └─────┴─────┴───────────┴───────────────┴─────┘</code></pre></div></div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#119-516">source</a><a href="#impl-Bytes" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#134-139">source</a><h4 class="code-header">pub const fn <a href="#method.new" class="fnname">new</a>() -> Self</h4></section></summary><div class="docblock"><p>Creates a new empty <code>Bytes</code>.</p> |
| <p>This will not allocate and the returned <code>Bytes</code> handle will be empty.</p> |
| <h5 id="examples"><a href="#examples">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span>b = Bytes::new(); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>b[..], <span class="string">b""</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_static" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#162-169">source</a><h4 class="code-header">pub const fn <a href="#method.from_static" class="fnname">from_static</a>(bytes: &'static [u8]) -> Self</h4></section></summary><div class="docblock"><p>Creates a new <code>Bytes</code> from a static slice.</p> |
| <p>The returned <code>Bytes</code> will point directly to the static slice. There is |
| no allocating or copying.</p> |
| <h5 id="examples-1"><a href="#examples-1">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span>b = Bytes::from_static(<span class="string">b"hello"</span>); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>b[..], <span class="string">b"hello"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#192-194">source</a><h4 class="code-header">pub const fn <a href="#method.len" class="fnname">len</a>(&self) -> usize</h4></section></summary><div class="docblock"><p>Returns the number of bytes contained in this <code>Bytes</code>.</p> |
| <h5 id="examples-2"><a href="#examples-2">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span>b = Bytes::from(<span class="kw-2">&</span><span class="string">b"hello"</span>[..]); |
| <span class="macro">assert_eq!</span>(b.len(), <span class="number">5</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_empty" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#207-209">source</a><h4 class="code-header">pub const fn <a href="#method.is_empty" class="fnname">is_empty</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns true if the <code>Bytes</code> has a length of 0.</p> |
| <h5 id="examples-3"><a href="#examples-3">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span>b = Bytes::new(); |
| <span class="macro">assert!</span>(b.is_empty());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.copy_from_slice" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#212-214">source</a><h4 class="code-header">pub fn <a href="#method.copy_from_slice" class="fnname">copy_from_slice</a>(data: &[u8]) -> Self</h4></section></summary><div class="docblock"><p>Creates <code>Bytes</code> instance from slice, by copying it.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.slice" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#238-278">source</a><h4 class="code-header">pub fn <a href="#method.slice" class="fnname">slice</a>(&self, range: impl RangeBounds<usize>) -> Self</h4></section></summary><div class="docblock"><p>Returns a slice of self for the provided range.</p> |
| <p>This will increment the reference count for the underlying memory and |
| return a new <code>Bytes</code> handle set to the slice.</p> |
| <p>This operation is <code>O(1)</code>.</p> |
| <h5 id="examples-4"><a href="#examples-4">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span>a = Bytes::from(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]); |
| <span class="kw">let </span>b = a.slice(<span class="number">2</span>..<span class="number">5</span>); |
| |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>b[..], <span class="string">b"llo"</span>);</code></pre></div> |
| <h5 id="panics"><a href="#panics">Panics</a></h5> |
| <p>Requires that <code>begin <= end</code> and <code>end <= self.len()</code>, otherwise slicing |
| will panic.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.slice_ref" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#305-336">source</a><h4 class="code-header">pub fn <a href="#method.slice_ref" class="fnname">slice_ref</a>(&self, subset: &[u8]) -> Self</h4></section></summary><div class="docblock"><p>Returns a slice of self that is equivalent to the given <code>subset</code>.</p> |
| <p>When processing a <code>Bytes</code> buffer with other tools, one often gets a |
| <code>&[u8]</code> which is in fact a slice of the <code>Bytes</code>, i.e. a subset of it. |
| This function turns that <code>&[u8]</code> into another <code>Bytes</code>, as if one had |
| called <code>self.slice()</code> with the offsets that correspond to <code>subset</code>.</p> |
| <p>This operation is <code>O(1)</code>.</p> |
| <h5 id="examples-5"><a href="#examples-5">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span>bytes = Bytes::from(<span class="kw-2">&</span><span class="string">b"012345678"</span>[..]); |
| <span class="kw">let </span>as_slice = bytes.as_ref(); |
| <span class="kw">let </span>subset = <span class="kw-2">&</span>as_slice[<span class="number">2</span>..<span class="number">6</span>]; |
| <span class="kw">let </span>subslice = bytes.slice_ref(<span class="kw-2">&</span>subset); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>subslice[..], <span class="string">b"2345"</span>);</code></pre></div> |
| <h5 id="panics-1"><a href="#panics-1">Panics</a></h5> |
| <p>Requires that the given <code>sub</code> slice is in fact contained within the |
| <code>Bytes</code> buffer; otherwise this function will panic.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_off" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#362-385">source</a><h4 class="code-header">pub fn <a href="#method.split_off" class="fnname">split_off</a>(&mut self, at: usize) -> Self</h4></section></summary><div class="docblock"><p>Splits the bytes into two at the given index.</p> |
| <p>Afterwards <code>self</code> contains elements <code>[0, at)</code>, and the returned <code>Bytes</code> |
| contains elements <code>[at, len)</code>.</p> |
| <p>This is an <code>O(1)</code> operation that just increases the reference count and |
| sets a few indices.</p> |
| <h5 id="examples-6"><a href="#examples-6">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = Bytes::from(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]); |
| <span class="kw">let </span>b = a.split_off(<span class="number">5</span>); |
| |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>a[..], <span class="string">b"hello"</span>); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>b[..], <span class="string">b" world"</span>);</code></pre></div> |
| <h5 id="panics-2"><a href="#panics-2">Panics</a></h5> |
| <p>Panics if <code>at > len</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_to" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#411-433">source</a><h4 class="code-header">pub fn <a href="#method.split_to" class="fnname">split_to</a>(&mut self, at: usize) -> Self</h4></section></summary><div class="docblock"><p>Splits the bytes into two at the given index.</p> |
| <p>Afterwards <code>self</code> contains elements <code>[at, len)</code>, and the returned |
| <code>Bytes</code> contains elements <code>[0, at)</code>.</p> |
| <p>This is an <code>O(1)</code> operation that just increases the reference count and |
| sets a few indices.</p> |
| <h5 id="examples-7"><a href="#examples-7">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>a = Bytes::from(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]); |
| <span class="kw">let </span>b = a.split_to(<span class="number">5</span>); |
| |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>a[..], <span class="string">b" world"</span>); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>b[..], <span class="string">b"hello"</span>);</code></pre></div> |
| <h5 id="panics-3"><a href="#panics-3">Panics</a></h5> |
| <p>Panics if <code>at > len</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.truncate" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#456-469">source</a><h4 class="code-header">pub fn <a href="#method.truncate" class="fnname">truncate</a>(&mut self, len: usize)</h4></section></summary><div class="docblock"><p>Shortens the buffer, keeping the first <code>len</code> bytes and dropping the |
| rest.</p> |
| <p>If <code>len</code> is greater than the buffer’s current length, this has no |
| effect.</p> |
| <p>The <a href="#method.split_off"><code>split_off</code></a> method can emulate <code>truncate</code>, but this causes the |
| excess bytes to be returned instead of dropped.</p> |
| <h5 id="examples-8"><a href="#examples-8">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>buf = Bytes::from(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]); |
| buf.truncate(<span class="number">5</span>); |
| <span class="macro">assert_eq!</span>(buf, <span class="string">b"hello"</span>[..]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clear" class="method has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#483-485">source</a><h4 class="code-header">pub fn <a href="#method.clear" class="fnname">clear</a>(&mut self)</h4></section></summary><div class="docblock"><p>Clears the buffer, removing all data.</p> |
| <h5 id="examples-9"><a href="#examples-9">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Bytes; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>buf = Bytes::from(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]); |
| buf.clear(); |
| <span class="macro">assert!</span>(buf.is_empty());</code></pre></div> |
| </div></details></div></details></div><h2 id="deref-methods-%5Bu8%5D" class="small-section-header"><span>Methods from Deref<Target = [u8]></span><a href="#deref-methods-%5Bu8%5D" class="anchor"></a></h2><div id="deref-methods-%5Bu8%5D-1"><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len-1" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.len-1" class="fnname">len</a>(&self) -> usize</h4></section></summary><div class="docblock"><p>Returns the number of elements in the slice.</p> |
| <h5 id="examples-10"><a href="#examples-10">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>a = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]; |
| <span class="macro">assert_eq!</span>(a.len(), <span class="number">3</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_empty-1" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.is_empty-1" class="fnname">is_empty</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the slice has a length of 0.</p> |
| <h5 id="examples-11"><a href="#examples-11">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>a = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]; |
| <span class="macro">assert!</span>(!a.is_empty());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.first" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.first" class="fnname">first</a>(&self) -> Option<&T></h4></section></summary><div class="docblock"><p>Returns the first element of the slice, or <code>None</code> if it is empty.</p> |
| <h5 id="examples-12"><a href="#examples-12">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">10</span>), v.first()); |
| |
| <span class="kw">let </span>w: <span class="kw-2">&</span>[i32] = <span class="kw-2">&</span>[]; |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, w.first());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_first" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.5.0">1.5.0</span><h4 class="code-header">pub fn <a href="#method.split_first" class="fnname">split_first</a>(&self) -> Option<(&T, &[T])></h4></section></summary><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> |
| <h5 id="examples-13"><a href="#examples-13">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>x = <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>]; |
| |
| <span class="kw">if let </span><span class="prelude-val">Some</span>((first, elements)) = x.split_first() { |
| <span class="macro">assert_eq!</span>(first, <span class="kw-2">&</span><span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(elements, <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>]); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_last" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.5.0">1.5.0</span><h4 class="code-header">pub fn <a href="#method.split_last" class="fnname">split_last</a>(&self) -> Option<(&T, &[T])></h4></section></summary><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> |
| <h5 id="examples-14"><a href="#examples-14">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>x = <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>]; |
| |
| <span class="kw">if let </span><span class="prelude-val">Some</span>((last, elements)) = x.split_last() { |
| <span class="macro">assert_eq!</span>(last, <span class="kw-2">&</span><span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(elements, <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>]); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.last" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.last" class="fnname">last</a>(&self) -> Option<&T></h4></section></summary><div class="docblock"><p>Returns the last element of the slice, or <code>None</code> if it is empty.</p> |
| <h5 id="examples-15"><a href="#examples-15">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">30</span>), v.last()); |
| |
| <span class="kw">let </span>w: <span class="kw-2">&</span>[i32] = <span class="kw-2">&</span>[]; |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, w.last());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.get" class="fnname">get</a><I>(&self, index: I) -> Option<&<I as SliceIndex<[T]>>::Output><span class="where fmt-newline">where<br> I: SliceIndex<[T]>,</span></h4></section></summary><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> |
| <h5 id="examples-16"><a href="#examples-16">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">40</span>), v.get(<span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>][..]), v.get(<span class="number">0</span>..<span class="number">2</span>)); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, v.get(<span class="number">3</span>)); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, v.get(<span class="number">0</span>..<span class="number">4</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_unchecked" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub unsafe fn <a href="#method.get_unchecked" class="fnname">get_unchecked</a><I>(<br> &self,<br> index: I<br>) -> &<I as SliceIndex<[T]>>::Output<span class="where fmt-newline">where<br> I: SliceIndex<[T]>,</span></h4></section></summary><div class="docblock"><p>Returns a reference to an element or subslice, without doing bounds |
| checking.</p> |
| <p>For a safe alternative see <a href="slice::get"><code>get</code></a>.</p> |
| <h5 id="safety"><a href="#safety">Safety</a></h5> |
| <p>Calling this method with an out-of-bounds index is <em><a href="https://doc.rust-lang.org/reference/behavior-considered-undefined.html">undefined behavior</a></em> |
| even if the resulting reference is not used.</p> |
| <h5 id="examples-17"><a href="#examples-17">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>x = <span class="kw-2">&</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>(x.get_unchecked(<span class="number">1</span>), <span class="kw-2">&</span><span class="number">2</span>); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_ptr" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.as_ptr" class="fnname">as_ptr</a>(&self) -> *const T</h4></section></summary><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>The caller must also ensure that the memory the pointer (non-transitively) points to |
| is never written to (except inside an <code>UnsafeCell</code>) using this pointer or any pointer |
| derived from it. If you need to mutate the contents of the slice, use <a href="slice::as_mut_ptr"><code>as_mut_ptr</code></a>.</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> |
| <h5 id="examples-18"><a href="#examples-18">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>x = <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>]; |
| <span class="kw">let </span>x_ptr = x.as_ptr(); |
| |
| <span class="kw">unsafe </span>{ |
| <span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..x.len() { |
| <span class="macro">assert_eq!</span>(x.get_unchecked(i), <span class="kw-2">&*</span>x_ptr.add(i)); |
| } |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_ptr_range" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.48.0">1.48.0</span><h4 class="code-header">pub fn <a href="#method.as_ptr_range" class="fnname">as_ptr_range</a>(&self) -> Range<*const T></h4></section></summary><div class="docblock"><p>Returns the two raw pointers spanning the slice.</p> |
| <p>The returned range is half-open, which means that the end pointer |
| points <em>one past</em> the last element of the slice. This way, an empty |
| slice is represented by two equal pointers, and the difference between |
| the two pointers represents the size of the slice.</p> |
| <p>See <a href="slice::as_ptr"><code>as_ptr</code></a> for warnings on using these pointers. The end pointer |
| requires extra caution, as it does not point to a valid element in the |
| slice.</p> |
| <p>This function is useful for interacting with foreign interfaces which |
| use two pointers to refer to a range of elements in memory, as is |
| common in C++.</p> |
| <p>It can also be useful to check if a pointer to an element refers to an |
| element of this slice:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>a = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]; |
| <span class="kw">let </span>x = <span class="kw-2">&</span>a[<span class="number">1</span>] <span class="kw">as </span><span class="kw-2">*const </span><span class="kw">_</span>; |
| <span class="kw">let </span>y = <span class="kw-2">&</span><span class="number">5 </span><span class="kw">as </span><span class="kw-2">*const </span><span class="kw">_</span>; |
| |
| <span class="macro">assert!</span>(a.as_ptr_range().contains(<span class="kw-2">&</span>x)); |
| <span class="macro">assert!</span>(!a.as_ptr_range().contains(<span class="kw-2">&</span>y));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.iter" class="fnname">iter</a>(&self) -> Iter<'_, T></h4></section></summary><div class="docblock"><p>Returns an iterator over the slice.</p> |
| <p>The iterator yields all items from start to end.</p> |
| <h5 id="examples-19"><a href="#examples-19">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>x = <span class="kw-2">&</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>iterator = x.iter(); |
| |
| <span class="macro">assert_eq!</span>(iterator.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(iterator.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">2</span>)); |
| <span class="macro">assert_eq!</span>(iterator.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">4</span>)); |
| <span class="macro">assert_eq!</span>(iterator.next(), <span class="prelude-val">None</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.windows" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.windows" class="fnname">windows</a>(&self, size: usize) -> Windows<'_, T></h4></section></summary><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> |
| <h5 id="panics-4"><a href="#panics-4">Panics</a></h5> |
| <p>Panics if <code>size</code> is 0.</p> |
| <h5 id="examples-20"><a href="#examples-20">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="string">'r'</span>, <span class="string">'u'</span>, <span class="string">'s'</span>, <span class="string">'t'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.windows(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'r'</span>, <span class="string">'u'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'u'</span>, <span class="string">'s'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'s'</span>, <span class="string">'t'</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| <p>If the slice is shorter than <code>size</code>:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="string">'f'</span>, <span class="string">'o'</span>, <span class="string">'o'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.windows(<span class="number">4</span>); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chunks" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.chunks" class="fnname">chunks</a>(&self, chunk_size: usize) -> Chunks<'_, T></h4></section></summary><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="slice::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="slice::rchunks"><code>rchunks</code></a> for the same iterator but starting at the end of the |
| slice.</p> |
| <h5 id="panics-5"><a href="#panics-5">Panics</a></h5> |
| <p>Panics if <code>chunk_size</code> is 0.</p> |
| <h5 id="examples-21"><a href="#examples-21">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.chunks(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'l'</span>, <span class="string">'o'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'r'</span>, <span class="string">'e'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'m'</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chunks_exact" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.31.0">1.31.0</span><h4 class="code-header">pub fn <a href="#method.chunks_exact" class="fnname">chunks_exact</a>(&self, chunk_size: usize) -> ChunksExact<'_, T></h4></section></summary><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="slice::chunks"><code>chunks</code></a>.</p> |
| <p>See <a href="slice::chunks"><code>chunks</code></a> for a variant of this iterator that also returns the remainder as a smaller |
| chunk, and <a href="slice::rchunks_exact"><code>rchunks_exact</code></a> for the same iterator but starting at the end of the slice.</p> |
| <h5 id="panics-6"><a href="#panics-6">Panics</a></h5> |
| <p>Panics if <code>chunk_size</code> is 0.</p> |
| <h5 id="examples-22"><a href="#examples-22">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.chunks_exact(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'l'</span>, <span class="string">'o'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'r'</span>, <span class="string">'e'</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none()); |
| <span class="macro">assert_eq!</span>(iter.remainder(), <span class="kw-2">&</span>[<span class="string">'m'</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_chunks_unchecked" class="method has-srclink"><h4 class="code-header">pub unsafe fn <a href="#method.as_chunks_unchecked" class="fnname">as_chunks_unchecked</a><const N: usize>(&self) -> &[[T; N]]</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>slice_as_chunks</code>)</span></div></span></summary><div class="docblock"><p>Splits the slice into a slice of <code>N</code>-element arrays, |
| assuming that there’s no remainder.</p> |
| <h5 id="safety-1"><a href="#safety-1">Safety</a></h5> |
| <p>This may only be called when</p> |
| <ul> |
| <li>The slice splits exactly into <code>N</code>-element chunks (aka <code>self.len() % N == 0</code>).</li> |
| <li><code>N != 0</code>.</li> |
| </ul> |
| <h5 id="examples-23"><a href="#examples-23">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_as_chunks)] |
| </span><span class="kw">let </span>slice: <span class="kw-2">&</span>[char] = <span class="kw-2">&</span>[<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>, <span class="string">'!'</span>]; |
| <span class="kw">let </span>chunks: <span class="kw-2">&</span>[[char; <span class="number">1</span>]] = |
| <span class="comment">// SAFETY: 1-element chunks never have remainder |
| </span><span class="kw">unsafe </span>{ slice.as_chunks_unchecked() }; |
| <span class="macro">assert_eq!</span>(chunks, <span class="kw-2">&</span>[[<span class="string">'l'</span>], [<span class="string">'o'</span>], [<span class="string">'r'</span>], [<span class="string">'e'</span>], [<span class="string">'m'</span>], [<span class="string">'!'</span>]]); |
| <span class="kw">let </span>chunks: <span class="kw-2">&</span>[[char; <span class="number">3</span>]] = |
| <span class="comment">// SAFETY: The slice length (6) is a multiple of 3 |
| </span><span class="kw">unsafe </span>{ slice.as_chunks_unchecked() }; |
| <span class="macro">assert_eq!</span>(chunks, <span class="kw-2">&</span>[[<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>], [<span class="string">'e'</span>, <span class="string">'m'</span>, <span class="string">'!'</span>]]); |
| |
| <span class="comment">// These would be unsound: |
| // let chunks: &[[_; 5]] = slice.as_chunks_unchecked() // The slice length is not a multiple of 5 |
| // let chunks: &[[_; 0]] = slice.as_chunks_unchecked() // Zero-length chunks are never allowed</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_chunks" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.as_chunks" class="fnname">as_chunks</a><const N: usize>(&self) -> (&[[T; N]], &[T])</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>slice_as_chunks</code>)</span></div></span></summary><div class="docblock"><p>Splits the slice into a slice of <code>N</code>-element arrays, |
| starting at the beginning of the slice, |
| and a remainder slice with length strictly less than <code>N</code>.</p> |
| <h5 id="panics-7"><a href="#panics-7">Panics</a></h5> |
| <p>Panics if <code>N</code> is 0. This check will most probably get changed to a compile time |
| error before this method gets stabilized.</p> |
| <h5 id="examples-24"><a href="#examples-24">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_as_chunks)] |
| </span><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span>(chunks, remainder) = slice.as_chunks(); |
| <span class="macro">assert_eq!</span>(chunks, <span class="kw-2">&</span>[[<span class="string">'l'</span>, <span class="string">'o'</span>], [<span class="string">'r'</span>, <span class="string">'e'</span>]]); |
| <span class="macro">assert_eq!</span>(remainder, <span class="kw-2">&</span>[<span class="string">'m'</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_rchunks" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.as_rchunks" class="fnname">as_rchunks</a><const N: usize>(&self) -> (&[T], &[[T; N]])</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>slice_as_chunks</code>)</span></div></span></summary><div class="docblock"><p>Splits the slice into a slice of <code>N</code>-element arrays, |
| starting at the end of the slice, |
| and a remainder slice with length strictly less than <code>N</code>.</p> |
| <h5 id="panics-8"><a href="#panics-8">Panics</a></h5> |
| <p>Panics if <code>N</code> is 0. This check will most probably get changed to a compile time |
| error before this method gets stabilized.</p> |
| <h5 id="examples-25"><a href="#examples-25">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_as_chunks)] |
| </span><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span>(remainder, chunks) = slice.as_rchunks(); |
| <span class="macro">assert_eq!</span>(remainder, <span class="kw-2">&</span>[<span class="string">'l'</span>]); |
| <span class="macro">assert_eq!</span>(chunks, <span class="kw-2">&</span>[[<span class="string">'o'</span>, <span class="string">'r'</span>], [<span class="string">'e'</span>, <span class="string">'m'</span>]]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.array_chunks" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.array_chunks" class="fnname">array_chunks</a><const N: usize>(&self) -> ArrayChunks<'_, T, N></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>array_chunks</code>)</span></div></span></summary><div class="docblock"><p>Returns an iterator over <code>N</code> elements of the slice at a time, starting at the |
| beginning of the slice.</p> |
| <p>The chunks are array references and do not overlap. If <code>N</code> does not divide the |
| length of the slice, then the last up to <code>N-1</code> elements will be omitted and can be |
| retrieved from the <code>remainder</code> function of the iterator.</p> |
| <p>This method is the const generic equivalent of <a href="slice::chunks_exact"><code>chunks_exact</code></a>.</p> |
| <h5 id="panics-9"><a href="#panics-9">Panics</a></h5> |
| <p>Panics if <code>N</code> is 0. This check will most probably get changed to a compile time |
| error before this method gets stabilized.</p> |
| <h5 id="examples-26"><a href="#examples-26">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(array_chunks)] |
| </span><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.array_chunks(); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'l'</span>, <span class="string">'o'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'r'</span>, <span class="string">'e'</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none()); |
| <span class="macro">assert_eq!</span>(iter.remainder(), <span class="kw-2">&</span>[<span class="string">'m'</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.array_windows" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.array_windows" class="fnname">array_windows</a><const N: usize>(&self) -> ArrayWindows<'_, T, N></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>array_windows</code>)</span></div></span></summary><div class="docblock"><p>Returns an iterator over overlapping windows of <code>N</code> elements of a slice, |
| starting at the beginning of the slice.</p> |
| <p>This is the const generic equivalent of <a href="slice::windows"><code>windows</code></a>.</p> |
| <p>If <code>N</code> is greater than the size of the slice, it will return no windows.</p> |
| <h5 id="panics-10"><a href="#panics-10">Panics</a></h5> |
| <p>Panics if <code>N</code> is 0. This check will most probably get changed to a compile time |
| error before this method gets stabilized.</p> |
| <h5 id="examples-27"><a href="#examples-27">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(array_windows)] |
| </span><span class="kw">let </span>slice = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.array_windows(); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">3</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.rchunks" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.31.0">1.31.0</span><h4 class="code-header">pub fn <a href="#method.rchunks" class="fnname">rchunks</a>(&self, chunk_size: usize) -> RChunks<'_, T></h4></section></summary><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="slice::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="slice::chunks"><code>chunks</code></a> for the same iterator but starting at the beginning |
| of the slice.</p> |
| <h5 id="panics-11"><a href="#panics-11">Panics</a></h5> |
| <p>Panics if <code>chunk_size</code> is 0.</p> |
| <h5 id="examples-28"><a href="#examples-28">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.rchunks(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'e'</span>, <span class="string">'m'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'o'</span>, <span class="string">'r'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'l'</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.rchunks_exact" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.31.0">1.31.0</span><h4 class="code-header">pub fn <a href="#method.rchunks_exact" class="fnname">rchunks_exact</a>(&self, chunk_size: usize) -> RChunksExact<'_, T></h4></section></summary><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 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="slice::rchunks"><code>rchunks</code></a>.</p> |
| <p>See <a href="slice::rchunks"><code>rchunks</code></a> for a variant of this iterator that also returns the remainder as a smaller |
| chunk, and <a href="slice::chunks_exact"><code>chunks_exact</code></a> for the same iterator but starting at the beginning of the |
| slice.</p> |
| <h5 id="panics-12"><a href="#panics-12">Panics</a></h5> |
| <p>Panics if <code>chunk_size</code> is 0.</p> |
| <h5 id="examples-29"><a href="#examples-29">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="string">'l'</span>, <span class="string">'o'</span>, <span class="string">'r'</span>, <span class="string">'e'</span>, <span class="string">'m'</span>]; |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.rchunks_exact(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'e'</span>, <span class="string">'m'</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="string">'o'</span>, <span class="string">'r'</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none()); |
| <span class="macro">assert_eq!</span>(iter.remainder(), <span class="kw-2">&</span>[<span class="string">'l'</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.group_by" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.group_by" class="fnname">group_by</a><F>(&self, pred: F) -> GroupBy<'_, T, F><span class="where fmt-newline">where<br> F: FnMut(&T, &T) -> bool,</span></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>slice_group_by</code>)</span></div></span></summary><div class="docblock"><p>Returns an iterator over the slice producing non-overlapping runs |
| of elements using the predicate to separate them.</p> |
| <p>The predicate is called on two elements following themselves, |
| it means the predicate is called on <code>slice[0]</code> and <code>slice[1]</code> |
| then on <code>slice[1]</code> and <code>slice[2]</code> and so on.</p> |
| <h5 id="examples-30"><a href="#examples-30">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_group_by)] |
| |
| </span><span class="kw">let </span>slice = <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">3</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">2</span>]; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.group_by(|a, b| a == b); |
| |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>][..])); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">3</span>, <span class="number">3</span>][..])); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">2</span>, <span class="number">2</span>][..])); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">None</span>);</code></pre></div> |
| <p>This method can be used to extract the sorted subslices:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_group_by)] |
| |
| </span><span class="kw">let </span>slice = <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>iter = slice.group_by(|a, b| a <= b); |
| |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][..])); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">3</span>][..])); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>][..])); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">None</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_at" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.split_at" class="fnname">split_at</a>(&self, mid: usize) -> (&[T], &[T])</h4></section></summary><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> |
| <h5 id="panics-13"><a href="#panics-13">Panics</a></h5> |
| <p>Panics if <code>mid > len</code>.</p> |
| <h5 id="examples-31"><a href="#examples-31">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<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>(left, right) = v.split_at(<span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(left, []); |
| <span class="macro">assert_eq!</span>(right, [<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>(left, right) = v.split_at(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(left, [<span class="number">1</span>, <span class="number">2</span>]); |
| <span class="macro">assert_eq!</span>(right, [<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>(left, right) = v.split_at(<span class="number">6</span>); |
| <span class="macro">assert_eq!</span>(left, [<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_eq!</span>(right, []); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_at_unchecked" class="method has-srclink"><h4 class="code-header">pub unsafe fn <a href="#method.split_at_unchecked" class="fnname">split_at_unchecked</a>(&self, mid: usize) -> (&[T], &[T])</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>slice_split_at_unchecked</code>)</span></div></span></summary><div class="docblock"><p>Divides one slice into two at an index, without doing bounds checking.</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> |
| <p>For a safe alternative see <a href="slice::split_at"><code>split_at</code></a>.</p> |
| <h5 id="safety-2"><a href="#safety-2">Safety</a></h5> |
| <p>Calling this method with an out-of-bounds index is <em><a href="https://doc.rust-lang.org/reference/behavior-considered-undefined.html">undefined behavior</a></em> |
| even if the resulting reference is not used. The caller has to ensure that |
| <code>0 <= mid <= self.len()</code>.</p> |
| <h5 id="examples-32"><a href="#examples-32">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_split_at_unchecked)] |
| |
| </span><span class="kw">let </span>v = [<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">unsafe </span>{ |
| <span class="kw">let </span>(left, right) = v.split_at_unchecked(<span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(left, []); |
| <span class="macro">assert_eq!</span>(right, [<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">unsafe </span>{ |
| <span class="kw">let </span>(left, right) = v.split_at_unchecked(<span class="number">2</span>); |
| <span class="macro">assert_eq!</span>(left, [<span class="number">1</span>, <span class="number">2</span>]); |
| <span class="macro">assert_eq!</span>(right, [<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]); |
| } |
| |
| <span class="kw">unsafe </span>{ |
| <span class="kw">let </span>(left, right) = v.split_at_unchecked(<span class="number">6</span>); |
| <span class="macro">assert_eq!</span>(left, [<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_eq!</span>(right, []); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_array_ref" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.split_array_ref" class="fnname">split_array_ref</a><const N: usize>(&self) -> (&[T; N], &[T])</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>split_array</code>)</span></div></span></summary><div class="docblock"><p>Divides one slice into an array and a remainder slice at an index.</p> |
| <p>The array will contain all indices from <code>[0, N)</code> (excluding |
| the index <code>N</code> itself) and the slice will contain all |
| indices from <code>[N, len)</code> (excluding the index <code>len</code> itself).</p> |
| <h5 id="panics-14"><a href="#panics-14">Panics</a></h5> |
| <p>Panics if <code>N > len</code>.</p> |
| <h5 id="examples-33"><a href="#examples-33">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(split_array)] |
| |
| </span><span class="kw">let </span>v = <span class="kw-2">&</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>(left, right) = v.split_array_ref::<<span class="number">0</span>>(); |
| <span class="macro">assert_eq!</span>(left, <span class="kw-2">&</span>[]); |
| <span class="macro">assert_eq!</span>(right, [<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>(left, right) = v.split_array_ref::<<span class="number">2</span>>(); |
| <span class="macro">assert_eq!</span>(left, <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>]); |
| <span class="macro">assert_eq!</span>(right, [<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>(left, right) = v.split_array_ref::<<span class="number">6</span>>(); |
| <span class="macro">assert_eq!</span>(left, <span class="kw-2">&</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_eq!</span>(right, []); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.rsplit_array_ref" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.rsplit_array_ref" class="fnname">rsplit_array_ref</a><const N: usize>(&self) -> (&[T], &[T; N])</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>split_array</code>)</span></div></span></summary><div class="docblock"><p>Divides one slice into an array and a remainder slice at an index from |
| the end.</p> |
| <p>The slice will contain all indices from <code>[0, len - N)</code> (excluding |
| the index <code>len - N</code> itself) and the array will contain all |
| indices from <code>[len - N, len)</code> (excluding the index <code>len</code> itself).</p> |
| <h5 id="panics-15"><a href="#panics-15">Panics</a></h5> |
| <p>Panics if <code>N > len</code>.</p> |
| <h5 id="examples-34"><a href="#examples-34">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(split_array)] |
| |
| </span><span class="kw">let </span>v = <span class="kw-2">&</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>(left, right) = v.rsplit_array_ref::<<span class="number">0</span>>(); |
| <span class="macro">assert_eq!</span>(left, [<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_eq!</span>(right, <span class="kw-2">&</span>[]); |
| } |
| |
| { |
| <span class="kw">let </span>(left, right) = v.rsplit_array_ref::<<span class="number">2</span>>(); |
| <span class="macro">assert_eq!</span>(left, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]); |
| <span class="macro">assert_eq!</span>(right, <span class="kw-2">&</span>[<span class="number">5</span>, <span class="number">6</span>]); |
| } |
| |
| { |
| <span class="kw">let </span>(left, right) = v.rsplit_array_ref::<<span class="number">6</span>>(); |
| <span class="macro">assert_eq!</span>(left, []); |
| <span class="macro">assert_eq!</span>(right, <span class="kw-2">&</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>]); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.split" class="fnname">split</a><F>(&self, pred: F) -> Split<'_, T, F><span class="where fmt-newline">where<br> F: FnMut(&T) -> bool,</span></h4></section></summary><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> |
| <h5 id="examples-35"><a href="#examples-35">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<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>iter = slice.split(|num| num % <span class="number">3 </span>== <span class="number">0</span>); |
| |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">20</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></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"><code><span class="kw">let </span>slice = [<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>iter = slice.split(|num| num % <span class="number">3 </span>== <span class="number">0</span>); |
| |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></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"><code><span class="kw">let </span>slice = [<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>iter = slice.split(|num| num % <span class="number">3 </span>== <span class="number">0</span>); |
| |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">10</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">20</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.split_inclusive" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.51.0">1.51.0</span><h4 class="code-header">pub fn <a href="#method.split_inclusive" class="fnname">split_inclusive</a><F>(&self, pred: F) -> SplitInclusive<'_, T, F><span class="where fmt-newline">where<br> F: FnMut(&T) -> bool,</span></h4></section></summary><div class="docblock"><p>Returns an iterator over subslices separated by elements that match |
| <code>pred</code>. The matched element is contained in the end of the previous |
| subslice as a terminator.</p> |
| <h5 id="examples-36"><a href="#examples-36">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<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>iter = slice.split_inclusive(|num| num % <span class="number">3 </span>== <span class="number">0</span>); |
| |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">33</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">20</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| <p>If the last element of the slice is matched, |
| that element will be considered the terminator of the preceding slice. |
| That slice will be the last item returned by the iterator.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<span class="number">3</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>iter = slice.split_inclusive(|num| num % <span class="number">3 </span>== <span class="number">0</span>); |
| |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">3</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">33</span>]); |
| <span class="macro">assert!</span>(iter.next().is_none());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.rsplit" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.27.0">1.27.0</span><h4 class="code-header">pub fn <a href="#method.rsplit" class="fnname">rsplit</a><F>(&self, pred: F) -> RSplit<'_, T, F><span class="where fmt-newline">where<br> F: FnMut(&T) -> bool,</span></h4></section></summary><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> |
| <h5 id="examples-37"><a href="#examples-37">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>slice = [<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>iter = slice.rsplit(|num| <span class="kw-2">*</span>num == <span class="number">0</span>); |
| |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">44</span>, <span class="number">55</span>]); |
| <span class="macro">assert_eq!</span>(iter.next().unwrap(), <span class="kw-2">&</span>[<span class="number">11</span>, <span class="number">22</span>, <span class="number">33</span>]); |
| <span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">None</span>);</code></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"><code><span class="kw">let </span>v = <span class="kw-2">&</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>it = v.rsplit(|n| <span class="kw-2">*</span>n % <span class="number">2 </span>== <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(it.next().unwrap(), <span class="kw-2">&</span>[]); |
| <span class="macro">assert_eq!</span>(it.next().unwrap(), <span class="kw-2">&</span>[<span class="number">3</span>, <span class="number">5</span>]); |
| <span class="macro">assert_eq!</span>(it.next().unwrap(), <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">1</span>]); |
| <span class="macro">assert_eq!</span>(it.next().unwrap(), <span class="kw-2">&</span>[]); |
| <span class="macro">assert_eq!</span>(it.next(), <span class="prelude-val">None</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.splitn" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.splitn" class="fnname">splitn</a><F>(&self, n: usize, pred: F) -> SplitN<'_, T, F><span class="where fmt-newline">where<br> F: FnMut(&T) -> bool,</span></h4></section></summary><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> |
| <h5 id="examples-38"><a href="#examples-38">Examples</a></h5> |
| <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"><code><span class="kw">let </span>v = [<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>group <span class="kw">in </span>v.splitn(<span class="number">2</span>, |num| <span class="kw-2">*</span>num % <span class="number">3 </span>== <span class="number">0</span>) { |
| <span class="macro">println!</span>(<span class="string">"{group:?}"</span>); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.rsplitn" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.rsplitn" class="fnname">rsplitn</a><F>(&self, n: usize, pred: F) -> RSplitN<'_, T, F><span class="where fmt-newline">where<br> F: FnMut(&T) -> bool,</span></h4></section></summary><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> |
| <h5 id="examples-39"><a href="#examples-39">Examples</a></h5> |
| <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"><code><span class="kw">let </span>v = [<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>group <span class="kw">in </span>v.rsplitn(<span class="number">2</span>, |num| <span class="kw-2">*</span>num % <span class="number">3 </span>== <span class="number">0</span>) { |
| <span class="macro">println!</span>(<span class="string">"{group:?}"</span>); |
| }</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.contains" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.contains" class="fnname">contains</a>(&self, x: &T) -> bool<span class="where fmt-newline">where<br> T: PartialEq<T>,</span></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the slice contains an element with the given value.</p> |
| <p>This operation is <em>O</em>(<em>n</em>).</p> |
| <p>Note that if you have a sorted slice, <a href="slice::binary_search"><code>binary_search</code></a> may be faster.</p> |
| <h5 id="examples-40"><a href="#examples-40">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert!</span>(v.contains(<span class="kw-2">&</span><span class="number">30</span>)); |
| <span class="macro">assert!</span>(!v.contains(<span class="kw-2">&</span><span class="number">50</span>));</code></pre></div> |
| <p>If you do not have a <code>&T</code>, but some other value that you can compare |
| with one (for example, <code>String</code> implements <code>PartialEq<str></code>), you can |
| use <code>iter().any</code>:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [String::from(<span class="string">"hello"</span>), String::from(<span class="string">"world"</span>)]; <span class="comment">// slice of `String` |
| </span><span class="macro">assert!</span>(v.iter().any(|e| e == <span class="string">"hello"</span>)); <span class="comment">// search with `&str` |
| </span><span class="macro">assert!</span>(!v.iter().any(|e| e == <span class="string">"hi"</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.starts_with" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.starts_with" class="fnname">starts_with</a>(&self, needle: &[T]) -> bool<span class="where fmt-newline">where<br> T: PartialEq<T>,</span></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>needle</code> is a prefix of the slice.</p> |
| <h5 id="examples-41"><a href="#examples-41">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert!</span>(v.starts_with(<span class="kw-2">&</span>[<span class="number">10</span>])); |
| <span class="macro">assert!</span>(v.starts_with(<span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>])); |
| <span class="macro">assert!</span>(!v.starts_with(<span class="kw-2">&</span>[<span class="number">50</span>])); |
| <span class="macro">assert!</span>(!v.starts_with(<span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">50</span>]));</code></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"><code><span class="kw">let </span>v = <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert!</span>(v.starts_with(<span class="kw-2">&</span>[])); |
| <span class="kw">let </span>v: <span class="kw-2">&</span>[u8] = <span class="kw-2">&</span>[]; |
| <span class="macro">assert!</span>(v.starts_with(<span class="kw-2">&</span>[]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ends_with" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.ends_with" class="fnname">ends_with</a>(&self, needle: &[T]) -> bool<span class="where fmt-newline">where<br> T: PartialEq<T>,</span></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>needle</code> is a suffix of the slice.</p> |
| <h5 id="examples-42"><a href="#examples-42">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert!</span>(v.ends_with(<span class="kw-2">&</span>[<span class="number">30</span>])); |
| <span class="macro">assert!</span>(v.ends_with(<span class="kw-2">&</span>[<span class="number">40</span>, <span class="number">30</span>])); |
| <span class="macro">assert!</span>(!v.ends_with(<span class="kw-2">&</span>[<span class="number">50</span>])); |
| <span class="macro">assert!</span>(!v.ends_with(<span class="kw-2">&</span>[<span class="number">50</span>, <span class="number">30</span>]));</code></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"><code><span class="kw">let </span>v = <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert!</span>(v.ends_with(<span class="kw-2">&</span>[])); |
| <span class="kw">let </span>v: <span class="kw-2">&</span>[u8] = <span class="kw-2">&</span>[]; |
| <span class="macro">assert!</span>(v.ends_with(<span class="kw-2">&</span>[]));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.strip_prefix" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.51.0">1.51.0</span><h4 class="code-header">pub fn <a href="#method.strip_prefix" class="fnname">strip_prefix</a><P>(&self, prefix: &P) -> Option<&[T]><span class="where fmt-newline">where<br> P: SlicePattern<Item = T> + ?Sized,<br> T: PartialEq<T>,</span></h4></section></summary><div class="docblock"><p>Returns a subslice with the prefix removed.</p> |
| <p>If the slice starts with <code>prefix</code>, returns the subslice after the prefix, wrapped in <code>Some</code>. |
| If <code>prefix</code> is empty, simply returns the original slice.</p> |
| <p>If the slice does not start with <code>prefix</code>, returns <code>None</code>.</p> |
| <h5 id="examples-43"><a href="#examples-43">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert_eq!</span>(v.strip_prefix(<span class="kw-2">&</span>[<span class="number">10</span>]), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">40</span>, <span class="number">30</span>][..])); |
| <span class="macro">assert_eq!</span>(v.strip_prefix(<span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>]), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">30</span>][..])); |
| <span class="macro">assert_eq!</span>(v.strip_prefix(<span class="kw-2">&</span>[<span class="number">50</span>]), <span class="prelude-val">None</span>); |
| <span class="macro">assert_eq!</span>(v.strip_prefix(<span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">50</span>]), <span class="prelude-val">None</span>); |
| |
| <span class="kw">let </span>prefix : <span class="kw-2">&</span>str = <span class="string">"he"</span>; |
| <span class="macro">assert_eq!</span>(<span class="string">b"hello"</span>.strip_prefix(prefix.as_bytes()), |
| <span class="prelude-val">Some</span>(<span class="string">b"llo"</span>.as_ref()));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.strip_suffix" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.51.0">1.51.0</span><h4 class="code-header">pub fn <a href="#method.strip_suffix" class="fnname">strip_suffix</a><P>(&self, suffix: &P) -> Option<&[T]><span class="where fmt-newline">where<br> P: SlicePattern<Item = T> + ?Sized,<br> T: PartialEq<T>,</span></h4></section></summary><div class="docblock"><p>Returns a subslice with the suffix removed.</p> |
| <p>If the slice ends with <code>suffix</code>, returns the subslice before the suffix, wrapped in <code>Some</code>. |
| If <code>suffix</code> is empty, simply returns the original slice.</p> |
| <p>If the slice does not end with <code>suffix</code>, returns <code>None</code>.</p> |
| <h5 id="examples-44"><a href="#examples-44">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = <span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="macro">assert_eq!</span>(v.strip_suffix(<span class="kw-2">&</span>[<span class="number">30</span>]), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">10</span>, <span class="number">40</span>][..])); |
| <span class="macro">assert_eq!</span>(v.strip_suffix(<span class="kw-2">&</span>[<span class="number">40</span>, <span class="number">30</span>]), <span class="prelude-val">Some</span>(<span class="kw-2">&</span>[<span class="number">10</span>][..])); |
| <span class="macro">assert_eq!</span>(v.strip_suffix(<span class="kw-2">&</span>[<span class="number">50</span>]), <span class="prelude-val">None</span>); |
| <span class="macro">assert_eq!</span>(v.strip_suffix(<span class="kw-2">&</span>[<span class="number">50</span>, <span class="number">30</span>]), <span class="prelude-val">None</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.binary_search" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.binary_search" class="fnname">binary_search</a>(&self, x: &T) -> Result<usize, usize><span class="where fmt-newline">where<br> T: Ord,</span></h4></section></summary><div class="docblock"><p>Binary searches this slice for a given element. |
| This behaves similarly to <a href="slice::contains"><code>contains</code></a> if this slice is sorted.</p> |
| <p>If the value is found then [<code>Result::Ok</code>] is returned, containing the |
| index of the matching element. If there are multiple matches, then any |
| one of the matches could be returned. The index is chosen |
| deterministically, but is subject to change in future versions of Rust. |
| If the value is not found then [<code>Result::Err</code>] is returned, containing |
| the index where a matching element could be inserted while maintaining |
| sorted order.</p> |
| <p>See also <a href="slice::binary_search_by"><code>binary_search_by</code></a>, <a href="slice::binary_search_by_key"><code>binary_search_by_key</code></a>, and <a href="slice::partition_point"><code>partition_point</code></a>.</p> |
| <h5 id="examples-45"><a href="#examples-45">Examples</a></h5> |
| <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"><code><span class="kw">let </span>s = [<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>(s.binary_search(<span class="kw-2">&</span><span class="number">13</span>), <span class="prelude-val">Ok</span>(<span class="number">9</span>)); |
| <span class="macro">assert_eq!</span>(s.binary_search(<span class="kw-2">&</span><span class="number">4</span>), <span class="prelude-val">Err</span>(<span class="number">7</span>)); |
| <span class="macro">assert_eq!</span>(s.binary_search(<span class="kw-2">&</span><span class="number">100</span>), <span class="prelude-val">Err</span>(<span class="number">13</span>)); |
| <span class="kw">let </span>r = s.binary_search(<span class="kw-2">&</span><span class="number">1</span>); |
| <span class="macro">assert!</span>(<span class="kw">match </span>r { <span class="prelude-val">Ok</span>(<span class="number">1</span>..=<span class="number">4</span>) => <span class="bool-val">true</span>, <span class="kw">_ </span>=> <span class="bool-val">false</span>, });</code></pre></div> |
| <p>If you want to find that whole <em>range</em> of matching items, rather than |
| an arbitrary matching one, that can be done using <a href="slice::partition_point"><code>partition_point</code></a>:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>s = [<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>low = s.partition_point(|x| x < <span class="kw-2">&</span><span class="number">1</span>); |
| <span class="macro">assert_eq!</span>(low, <span class="number">1</span>); |
| <span class="kw">let </span>high = s.partition_point(|x| x <= <span class="kw-2">&</span><span class="number">1</span>); |
| <span class="macro">assert_eq!</span>(high, <span class="number">5</span>); |
| <span class="kw">let </span>r = s.binary_search(<span class="kw-2">&</span><span class="number">1</span>); |
| <span class="macro">assert!</span>((low..high).contains(<span class="kw-2">&</span>r.unwrap())); |
| |
| <span class="macro">assert!</span>(s[..low].iter().all(|<span class="kw-2">&</span>x| x < <span class="number">1</span>)); |
| <span class="macro">assert!</span>(s[low..high].iter().all(|<span class="kw-2">&</span>x| x == <span class="number">1</span>)); |
| <span class="macro">assert!</span>(s[high..].iter().all(|<span class="kw-2">&</span>x| x > <span class="number">1</span>)); |
| |
| <span class="comment">// For something not found, the "range" of equal items is empty |
| </span><span class="macro">assert_eq!</span>(s.partition_point(|x| x < <span class="kw-2">&</span><span class="number">11</span>), <span class="number">9</span>); |
| <span class="macro">assert_eq!</span>(s.partition_point(|x| x <= <span class="kw-2">&</span><span class="number">11</span>), <span class="number">9</span>); |
| <span class="macro">assert_eq!</span>(s.binary_search(<span class="kw-2">&</span><span class="number">11</span>), <span class="prelude-val">Err</span>(<span class="number">9</span>));</code></pre></div> |
| <p>If you want to insert an item to a sorted vector, while maintaining |
| sort order, consider using <a href="slice::partition_point"><code>partition_point</code></a>:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>s = <span class="macro">vec!</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>num = <span class="number">42</span>; |
| <span class="kw">let </span>idx = s.partition_point(|<span class="kw-2">&</span>x| x < num); |
| <span class="comment">// The above is equivalent to `let idx = s.binary_search(&num).unwrap_or_else(|x| x);` |
| </span>s.insert(idx, num); |
| <span class="macro">assert_eq!</span>(s, [<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">42</span>, <span class="number">55</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.binary_search_by" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.binary_search_by" class="fnname">binary_search_by</a><'a, F>(&'a self, f: F) -> Result<usize, usize><span class="where fmt-newline">where<br> F: FnMut(&'a T) -> Ordering,</span></h4></section></summary><div class="docblock"><p>Binary searches this slice with a comparator function. |
| This behaves similarly to <a href="slice::contains"><code>contains</code></a> if this slice is sorted.</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 [<code>Result::Ok</code>] is returned, containing the |
| index of the matching element. If there are multiple matches, then any |
| one of the matches could be returned. The index is chosen |
| deterministically, but is subject to change in future versions of Rust. |
| If the value is not found then [<code>Result::Err</code>] is returned, containing |
| the index where a matching element could be inserted while maintaining |
| sorted order.</p> |
| <p>See also <a href="slice::binary_search"><code>binary_search</code></a>, <a href="slice::binary_search_by_key"><code>binary_search_by_key</code></a>, and <a href="slice::partition_point"><code>partition_point</code></a>.</p> |
| <h5 id="examples-46"><a href="#examples-46">Examples</a></h5> |
| <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"><code><span class="kw">let </span>s = [<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>seek = <span class="number">13</span>; |
| <span class="macro">assert_eq!</span>(s.binary_search_by(|probe| probe.cmp(<span class="kw-2">&</span>seek)), <span class="prelude-val">Ok</span>(<span class="number">9</span>)); |
| <span class="kw">let </span>seek = <span class="number">4</span>; |
| <span class="macro">assert_eq!</span>(s.binary_search_by(|probe| probe.cmp(<span class="kw-2">&</span>seek)), <span class="prelude-val">Err</span>(<span class="number">7</span>)); |
| <span class="kw">let </span>seek = <span class="number">100</span>; |
| <span class="macro">assert_eq!</span>(s.binary_search_by(|probe| probe.cmp(<span class="kw-2">&</span>seek)), <span class="prelude-val">Err</span>(<span class="number">13</span>)); |
| <span class="kw">let </span>seek = <span class="number">1</span>; |
| <span class="kw">let </span>r = s.binary_search_by(|probe| probe.cmp(<span class="kw-2">&</span>seek)); |
| <span class="macro">assert!</span>(<span class="kw">match </span>r { <span class="prelude-val">Ok</span>(<span class="number">1</span>..=<span class="number">4</span>) => <span class="bool-val">true</span>, <span class="kw">_ </span>=> <span class="bool-val">false</span>, });</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.binary_search_by_key" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.10.0">1.10.0</span><h4 class="code-header">pub fn <a href="#method.binary_search_by_key" class="fnname">binary_search_by_key</a><'a, B, F>(<br> &'a self,<br> b: &B,<br> f: F<br>) -> Result<usize, usize><span class="where fmt-newline">where<br> F: FnMut(&'a T) -> B,<br> B: Ord,</span></h4></section></summary><div class="docblock"><p>Binary searches this slice with a key extraction function. |
| This behaves similarly to <a href="slice::contains"><code>contains</code></a> if this slice is sorted.</p> |
| <p>Assumes that the slice is sorted by the key, for instance with |
| <a href="slice::sort_by_key"><code>sort_by_key</code></a> using the same key extraction function.</p> |
| <p>If the value is found then [<code>Result::Ok</code>] is returned, containing the |
| index of the matching element. If there are multiple matches, then any |
| one of the matches could be returned. The index is chosen |
| deterministically, but is subject to change in future versions of Rust. |
| If the value is not found then [<code>Result::Err</code>] is returned, containing |
| the index where a matching element could be inserted while maintaining |
| sorted order.</p> |
| <p>See also <a href="slice::binary_search"><code>binary_search</code></a>, <a href="slice::binary_search_by"><code>binary_search_by</code></a>, and <a href="slice::partition_point"><code>partition_point</code></a>.</p> |
| <h5 id="examples-47"><a href="#examples-47">Examples</a></h5> |
| <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"><code><span class="kw">let </span>s = [(<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>(s.binary_search_by_key(<span class="kw-2">&</span><span class="number">13</span>, |<span class="kw-2">&</span>(a, b)| b), <span class="prelude-val">Ok</span>(<span class="number">9</span>)); |
| <span class="macro">assert_eq!</span>(s.binary_search_by_key(<span class="kw-2">&</span><span class="number">4</span>, |<span class="kw-2">&</span>(a, b)| b), <span class="prelude-val">Err</span>(<span class="number">7</span>)); |
| <span class="macro">assert_eq!</span>(s.binary_search_by_key(<span class="kw-2">&</span><span class="number">100</span>, |<span class="kw-2">&</span>(a, b)| b), <span class="prelude-val">Err</span>(<span class="number">13</span>)); |
| <span class="kw">let </span>r = s.binary_search_by_key(<span class="kw-2">&</span><span class="number">1</span>, |<span class="kw-2">&</span>(a, b)| b); |
| <span class="macro">assert!</span>(<span class="kw">match </span>r { <span class="prelude-val">Ok</span>(<span class="number">1</span>..=<span class="number">4</span>) => <span class="bool-val">true</span>, <span class="kw">_ </span>=> <span class="bool-val">false</span>, });</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.align_to" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.30.0">1.30.0</span><h4 class="code-header">pub unsafe fn <a href="#method.align_to" class="fnname">align_to</a><U>(&self) -> (&[T], &[U], &[T])</h4></section></summary><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 may 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. It is permissible for all of the input data to |
| be returned as the prefix or suffix slice.</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> |
| <h5 id="safety-3"><a href="#safety-3">Safety</a></h5> |
| <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::<T, U></code> also apply here.</p> |
| <h5 id="examples-48"><a href="#examples-48">Examples</a></h5> |
| <p>Basic usage:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">unsafe </span>{ |
| <span class="kw">let </span>bytes: [u8; <span class="number">7</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>(prefix, shorts, suffix) = bytes.align_to::<u16>(); |
| <span class="comment">// less_efficient_algorithm_for_bytes(prefix); |
| // more_efficient_algorithm_for_aligned_shorts(shorts); |
| // less_efficient_algorithm_for_bytes(suffix); |
| </span>}</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_simd" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.as_simd" class="fnname">as_simd</a><const LANES: usize>(&self) -> (&[T], &[Simd<T, LANES>], &[T])<span class="where fmt-newline">where<br> Simd<T, LANES>: AsRef<[T; LANES]>,<br> T: SimdElement,<br> LaneCount<LANES>: SupportedLaneCount,</span></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>portable_simd</code>)</span></div></span></summary><div class="docblock"><p>Split a slice into a prefix, a middle of aligned SIMD types, and a suffix.</p> |
| <p>This is a safe wrapper around [<code>slice::align_to</code>], so has the same weak |
| postconditions as that method. You’re only assured that |
| <code>self.len() == prefix.len() + middle.len() * LANES + suffix.len()</code>.</p> |
| <p>Notably, all of the following are possible:</p> |
| <ul> |
| <li><code>prefix.len() >= LANES</code>.</li> |
| <li><code>middle.is_empty()</code> despite <code>self.len() >= 3 * LANES</code>.</li> |
| <li><code>suffix.len() >= LANES</code>.</li> |
| </ul> |
| <p>That said, this is a safe method, so if you’re only writing safe code, |
| then this can at most cause incorrect logic, not unsoundness.</p> |
| <h5 id="panics-16"><a href="#panics-16">Panics</a></h5> |
| <p>This will panic if the size of the SIMD type is different from |
| <code>LANES</code> times that of the scalar.</p> |
| <p>At the time of writing, the trait restrictions on <code>Simd<T, LANES></code> keeps |
| that from ever happening, as only power-of-two numbers of lanes are |
| supported. It’s possible that, in the future, those restrictions might |
| be lifted in a way that would make it possible to see panics from this |
| method for something like <code>LANES == 3</code>.</p> |
| <h5 id="examples-49"><a href="#examples-49">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(portable_simd)] |
| </span><span class="kw">use </span>core::simd::SimdFloat; |
| |
| <span class="kw">let </span>short = <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]; |
| <span class="kw">let </span>(prefix, middle, suffix) = short.as_simd::<<span class="number">4</span>>(); |
| <span class="macro">assert_eq!</span>(middle, []); <span class="comment">// Not enough elements for anything in the middle |
| |
| // They might be split in any possible way between prefix and suffix |
| </span><span class="kw">let </span>it = prefix.iter().chain(suffix).copied(); |
| <span class="macro">assert_eq!</span>(it.collect::<Vec<<span class="kw">_</span>>>(), <span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]); |
| |
| <span class="kw">fn </span>basic_simd_sum(x: <span class="kw-2">&</span>[f32]) -> f32 { |
| <span class="kw">use </span>std::ops::Add; |
| <span class="kw">use </span>std::simd::f32x4; |
| <span class="kw">let </span>(prefix, middle, suffix) = x.as_simd(); |
| <span class="kw">let </span>sums = f32x4::from_array([ |
| prefix.iter().copied().sum(), |
| <span class="number">0.0</span>, |
| <span class="number">0.0</span>, |
| suffix.iter().copied().sum(), |
| ]); |
| <span class="kw">let </span>sums = middle.iter().copied().fold(sums, f32x4::add); |
| sums.reduce_sum() |
| } |
| |
| <span class="kw">let </span>numbers: Vec<f32> = (<span class="number">1</span>..<span class="number">101</span>).map(|x| x <span class="kw">as _</span>).collect(); |
| <span class="macro">assert_eq!</span>(basic_simd_sum(<span class="kw-2">&</span>numbers[<span class="number">1</span>..<span class="number">99</span>]), <span class="number">4949.0</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_sorted" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.is_sorted" class="fnname">is_sorted</a>(&self) -> bool<span class="where fmt-newline">where<br> T: PartialOrd<T>,</span></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>is_sorted</code>)</span></div></span></summary><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 <= 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> |
| <h5 id="examples-50"><a href="#examples-50">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(is_sorted)] |
| </span><span class="kw">let </span>empty: [i32; <span class="number">0</span>] = []; |
| |
| <span class="macro">assert!</span>([<span class="number">1</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">9</span>].is_sorted()); |
| <span class="macro">assert!</span>(![<span class="number">1</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">4</span>].is_sorted()); |
| <span class="macro">assert!</span>([<span class="number">0</span>].is_sorted()); |
| <span class="macro">assert!</span>(empty.is_sorted()); |
| <span class="macro">assert!</span>(![<span class="number">0.0</span>, <span class="number">1.0</span>, f32::NAN].is_sorted());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_sorted_by" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.is_sorted_by" class="fnname">is_sorted_by</a><F>(&self, compare: F) -> bool<span class="where fmt-newline">where<br> F: FnMut(&T, &T) -> Option<Ordering>,</span></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>is_sorted</code>)</span></div></span></summary><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="slice::is_sorted"><code>is_sorted</code></a>; see its documentation for more information.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_sorted_by_key" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.is_sorted_by_key" class="fnname">is_sorted_by_key</a><F, K>(&self, f: F) -> bool<span class="where fmt-newline">where<br> F: FnMut(&T) -> K,<br> K: PartialOrd<K>,</span></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>is_sorted</code>)</span></div></span></summary><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="slice::is_sorted"><code>is_sorted</code></a>; see its |
| documentation for more information.</p> |
| <h5 id="examples-51"><a href="#examples-51">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(is_sorted)] |
| |
| </span><span class="macro">assert!</span>([<span class="string">"c"</span>, <span class="string">"bb"</span>, <span class="string">"aaa"</span>].is_sorted_by_key(|s| s.len())); |
| <span class="macro">assert!</span>(![-<span class="number">2i32</span>, -<span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>].is_sorted_by_key(|n| n.abs()));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partition_point" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.52.0">1.52.0</span><h4 class="code-header">pub fn <a href="#method.partition_point" class="fnname">partition_point</a><P>(&self, pred: P) -> usize<span class="where fmt-newline">where<br> P: FnMut(&T) -> bool,</span></h4></section></summary><div class="docblock"><p>Returns the index of the partition point according to the given predicate |
| (the index of the first element of the second partition).</p> |
| <p>The slice is assumed to be partitioned according to the given predicate. |
| This means that all elements for which the predicate returns true are at the start of the slice |
| and all elements for which the predicate returns false are at the end. |
| For example, [7, 15, 3, 5, 4, 12, 6] is a partitioned under the predicate x % 2 != 0 |
| (all odd numbers are at the start, all even at the end).</p> |
| <p>If this slice is not partitioned, the returned result is unspecified and meaningless, |
| as this method performs a kind of binary search.</p> |
| <p>See also <a href="slice::binary_search"><code>binary_search</code></a>, <a href="slice::binary_search_by"><code>binary_search_by</code></a>, and <a href="slice::binary_search_by_key"><code>binary_search_by_key</code></a>.</p> |
| <h5 id="examples-52"><a href="#examples-52">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>v = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>]; |
| <span class="kw">let </span>i = v.partition_point(|<span class="kw-2">&</span>x| x < <span class="number">5</span>); |
| |
| <span class="macro">assert_eq!</span>(i, <span class="number">4</span>); |
| <span class="macro">assert!</span>(v[..i].iter().all(|<span class="kw-2">&</span>x| x < <span class="number">5</span>)); |
| <span class="macro">assert!</span>(v[i..].iter().all(|<span class="kw-2">&</span>x| !(x < <span class="number">5</span>)));</code></pre></div> |
| <p>If all elements of the slice match the predicate, including if the slice |
| is empty, then the length of the slice will be returned:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>a = [<span class="number">2</span>, <span class="number">4</span>, <span class="number">8</span>]; |
| <span class="macro">assert_eq!</span>(a.partition_point(|x| x < <span class="kw-2">&</span><span class="number">100</span>), a.len()); |
| <span class="kw">let </span>a: [i32; <span class="number">0</span>] = []; |
| <span class="macro">assert_eq!</span>(a.partition_point(|x| x < <span class="kw-2">&</span><span class="number">100</span>), <span class="number">0</span>);</code></pre></div> |
| <p>If you want to insert an item to a sorted vector, while maintaining |
| sort order:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>s = <span class="macro">vec!</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>num = <span class="number">42</span>; |
| <span class="kw">let </span>idx = s.partition_point(|<span class="kw-2">&</span>x| x < num); |
| s.insert(idx, num); |
| <span class="macro">assert_eq!</span>(s, [<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">42</span>, <span class="number">55</span>]);</code></pre></div> |
| </div></details></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.flatten" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.flatten" class="fnname">flatten</a>(&self) -> &[T]</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>slice_flatten</code>)</span></div></span></summary><div class="docblock"><p>Takes a <code>&[[T; N]]</code>, and flattens it to a <code>&[T]</code>.</p> |
| <h5 id="panics-17"><a href="#panics-17">Panics</a></h5> |
| <p>This panics if the length of the resulting slice would overflow a <code>usize</code>.</p> |
| <p>This is only possible when flattening a slice of arrays of zero-sized |
| types, and thus tends to be irrelevant in practice. If |
| <code>size_of::<T>() > 0</code>, this will never panic.</p> |
| <h5 id="examples-53"><a href="#examples-53">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(slice_flatten)] |
| |
| </span><span class="macro">assert_eq!</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>]].flatten(), <span class="kw-2">&</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_eq!</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>]].flatten(), |
| [[<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>]].flatten(), |
| ); |
| |
| <span class="kw">let </span>slice_of_empty_arrays: <span class="kw-2">&</span>[[i32; <span class="number">0</span>]] = <span class="kw-2">&</span>[[], [], [], [], []]; |
| <span class="macro">assert!</span>(slice_of_empty_arrays.flatten().is_empty()); |
| |
| <span class="kw">let </span>empty_slice_of_arrays: <span class="kw-2">&</span>[[u32; <span class="number">10</span>]] = <span class="kw-2">&</span>[]; |
| <span class="macro">assert!</span>(empty_slice_of_arrays.flatten().is_empty());</code></pre></div> |
| </div></details></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_ascii" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.23.0">1.23.0</span><h4 class="code-header">pub fn <a href="#method.is_ascii" class="fnname">is_ascii</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Checks if all bytes in this slice are within the ASCII range.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq_ignore_ascii_case" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.23.0">1.23.0</span><h4 class="code-header">pub fn <a href="#method.eq_ignore_ascii_case" class="fnname">eq_ignore_ascii_case</a>(&self, other: &[u8]) -> bool</h4></section></summary><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></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.escape_ascii" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.60.0">1.60.0</span><h4 class="code-header">pub fn <a href="#method.escape_ascii" class="fnname">escape_ascii</a>(&self) -> EscapeAscii<'_></h4></section></summary><div class="docblock"><p>Returns an iterator that produces an escaped version of this slice, |
| treating it as an ASCII string.</p> |
| <h5 id="examples-54"><a href="#examples-54">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code> |
| <span class="kw">let </span>s = <span class="string">b"0\t\r\n'\"\\\x9d"</span>; |
| <span class="kw">let </span>escaped = s.escape_ascii().to_string(); |
| <span class="macro">assert_eq!</span>(escaped, <span class="string">"0\\t\\r\\n\\'\\\"\\\\\\x9d"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.trim_ascii_start" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.trim_ascii_start" class="fnname">trim_ascii_start</a>(&self) -> &[u8]</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>byte_slice_trim_ascii</code>)</span></div></span></summary><div class="docblock"><p>Returns a byte slice with leading ASCII whitespace bytes removed.</p> |
| <p>‘Whitespace’ refers to the definition used by |
| <code>u8::is_ascii_whitespace</code>.</p> |
| <h5 id="examples-55"><a href="#examples-55">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(byte_slice_trim_ascii)] |
| |
| </span><span class="macro">assert_eq!</span>(<span class="string">b" \t hello world\n"</span>.trim_ascii_start(), <span class="string">b"hello world\n"</span>); |
| <span class="macro">assert_eq!</span>(<span class="string">b" "</span>.trim_ascii_start(), <span class="string">b""</span>); |
| <span class="macro">assert_eq!</span>(<span class="string">b""</span>.trim_ascii_start(), <span class="string">b""</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.trim_ascii_end" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.trim_ascii_end" class="fnname">trim_ascii_end</a>(&self) -> &[u8]</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>byte_slice_trim_ascii</code>)</span></div></span></summary><div class="docblock"><p>Returns a byte slice with trailing ASCII whitespace bytes removed.</p> |
| <p>‘Whitespace’ refers to the definition used by |
| <code>u8::is_ascii_whitespace</code>.</p> |
| <h5 id="examples-56"><a href="#examples-56">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(byte_slice_trim_ascii)] |
| |
| </span><span class="macro">assert_eq!</span>(<span class="string">b"\r hello world\n "</span>.trim_ascii_end(), <span class="string">b"\r hello world"</span>); |
| <span class="macro">assert_eq!</span>(<span class="string">b" "</span>.trim_ascii_end(), <span class="string">b""</span>); |
| <span class="macro">assert_eq!</span>(<span class="string">b""</span>.trim_ascii_end(), <span class="string">b""</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.trim_ascii" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.trim_ascii" class="fnname">trim_ascii</a>(&self) -> &[u8]</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>byte_slice_trim_ascii</code>)</span></div></span></summary><div class="docblock"><p>Returns a byte slice with leading and trailing ASCII whitespace bytes |
| removed.</p> |
| <p>‘Whitespace’ refers to the definition used by |
| <code>u8::is_ascii_whitespace</code>.</p> |
| <h5 id="examples-57"><a href="#examples-57">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(byte_slice_trim_ascii)] |
| |
| </span><span class="macro">assert_eq!</span>(<span class="string">b"\r hello world\n "</span>.trim_ascii(), <span class="string">b"hello world"</span>); |
| <span class="macro">assert_eq!</span>(<span class="string">b" "</span>.trim_ascii(), <span class="string">b""</span>); |
| <span class="macro">assert_eq!</span>(<span class="string">b""</span>.trim_ascii(), <span class="string">b""</span>);</code></pre></div> |
| </div></details></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_ascii_uppercase" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.23.0">1.23.0</span><h4 class="code-header">pub fn <a href="#method.to_ascii_uppercase" class="fnname">to_ascii_uppercase</a>(&self) -> Vec<u8, Global></h4></section></summary><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="slice::make_ascii_uppercase"><code>make_ascii_uppercase</code></a>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_ascii_lowercase" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.23.0">1.23.0</span><h4 class="code-header">pub fn <a href="#method.to_ascii_lowercase" class="fnname">to_ascii_lowercase</a>(&self) -> Vec<u8, Global></h4></section></summary><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="slice::make_ascii_lowercase"><code>make_ascii_lowercase</code></a>.</p> |
| </div></details></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_vec" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.to_vec" class="fnname">to_vec</a>(&self) -> Vec<T, Global><span class="where fmt-newline">where<br> T: Clone,</span></h4></section></summary><div class="docblock"><p>Copies <code>self</code> into a new <code>Vec</code>.</p> |
| <h5 id="examples-58"><a href="#examples-58">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>s = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="kw">let </span>x = s.to_vec(); |
| <span class="comment">// Here, `s` and `x` can be modified independently.</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_vec_in" class="method has-srclink"><h4 class="code-header">pub fn <a href="#method.to_vec_in" class="fnname">to_vec_in</a><A>(&self, alloc: A) -> Vec<T, A><span class="where fmt-newline">where<br> A: Allocator,<br> T: Clone,</span></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>allocator_api</code>)</span></div></span></summary><div class="docblock"><p>Copies <code>self</code> into a new <code>Vec</code> with an allocator.</p> |
| <h5 id="examples-59"><a href="#examples-59">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attribute">#![feature(allocator_api)] |
| |
| </span><span class="kw">use </span>std::alloc::System; |
| |
| <span class="kw">let </span>s = [<span class="number">10</span>, <span class="number">40</span>, <span class="number">30</span>]; |
| <span class="kw">let </span>x = s.to_vec_in(System); |
| <span class="comment">// Here, `s` and `x` can be modified independently.</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.repeat" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.40.0">1.40.0</span><h4 class="code-header">pub fn <a href="#method.repeat" class="fnname">repeat</a>(&self, n: usize) -> Vec<T, Global><span class="where fmt-newline">where<br> T: Copy,</span></h4></section></summary><div class="docblock"><p>Creates a vector by repeating a slice <code>n</code> times.</p> |
| <h5 id="panics-18"><a href="#panics-18">Panics</a></h5> |
| <p>This function will panic if the capacity would overflow.</p> |
| <h5 id="examples-60"><a href="#examples-60">Examples</a></h5> |
| <p>Basic usage:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>([<span class="number">1</span>, <span class="number">2</span>].repeat(<span class="number">3</span>), <span class="macro">vec!</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>]);</code></pre></div> |
| <p>A panic upon overflow:</p> |
| |
| <div class="example-wrap should_panic"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="comment">// this will panic at runtime |
| </span><span class="string">b"0123456789abcdef"</span>.repeat(usize::MAX);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.concat" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.concat" class="fnname">concat</a><Item>(&self) -> <[T] as Concat<Item>>::Output<span class="where fmt-newline">where<br> [T]: Concat<Item>,<br> Item: ?Sized,</span></h4></section></summary><div class="docblock"><p>Flattens a slice of <code>T</code> into a single value <code>Self::Output</code>.</p> |
| <h5 id="examples-61"><a href="#examples-61">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>([<span class="string">"hello"</span>, <span class="string">"world"</span>].concat(), <span class="string">"helloworld"</span>); |
| <span class="macro">assert_eq!</span>([[<span class="number">1</span>, <span class="number">2</span>], [<span class="number">3</span>, <span class="number">4</span>]].concat(), [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.join" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.3.0">1.3.0</span><h4 class="code-header">pub fn <a href="#method.join" class="fnname">join</a><Separator>(&self, sep: Separator) -> <[T] as Join<Separator>>::Output<span class="where fmt-newline">where<br> [T]: Join<Separator>,</span></h4></section></summary><div class="docblock"><p>Flattens a slice of <code>T</code> into a single value <code>Self::Output</code>, placing a |
| given separator between each.</p> |
| <h5 id="examples-62"><a href="#examples-62">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>([<span class="string">"hello"</span>, <span class="string">"world"</span>].join(<span class="string">" "</span>), <span class="string">"hello world"</span>); |
| <span class="macro">assert_eq!</span>([[<span class="number">1</span>, <span class="number">2</span>], [<span class="number">3</span>, <span class="number">4</span>]].join(<span class="kw-2">&</span><span class="number">0</span>), [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">4</span>]); |
| <span class="macro">assert_eq!</span>([[<span class="number">1</span>, <span class="number">2</span>], [<span class="number">3</span>, <span class="number">4</span>]].join(<span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">0</span>][..]), [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">4</span>]);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.connect" class="method has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h4 class="code-header">pub fn <a href="#method.connect" class="fnname">connect</a><Separator>(<br> &self,<br> sep: Separator<br>) -> <[T] as Join<Separator>>::Output<span class="where fmt-newline">where<br> [T]: Join<Separator>,</span></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 1.3.0: renamed to join</span></div></span></summary><div class="docblock"><p>Flattens a slice of <code>T</code> into a single value <code>Self::Output</code>, placing a |
| given separator between each.</p> |
| <h5 id="examples-63"><a href="#examples-63">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>([<span class="string">"hello"</span>, <span class="string">"world"</span>].connect(<span class="string">" "</span>), <span class="string">"hello world"</span>); |
| <span class="macro">assert_eq!</span>([[<span class="number">1</span>, <span class="number">2</span>], [<span class="number">3</span>, <span class="number">4</span>]].connect(<span class="kw-2">&</span><span class="number">0</span>), [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">4</span>]);</code></pre></div> |
| </div></details></div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AsRef%3C%5Bu8%5D%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#581-586">source</a><a href="#impl-AsRef%3C%5Bu8%5D%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl AsRef<[u8]> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_ref" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#583-585">source</a><a href="#method.as_ref" class="anchor"></a><h4 class="code-header">fn <a class="fnname">as_ref</a>(&self) -> &[u8]</h4></section></summary><div class='docblock'>Converts this type into a shared reference of the (usually inferred) input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Borrow%3C%5Bu8%5D%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#597-601">source</a><a href="#impl-Borrow%3C%5Bu8%5D%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl Borrow<[u8]> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#598-600">source</a><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow</a>(&self) -> &[u8]</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Buf-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#536-570">source</a><a href="#impl-Buf-for-Bytes" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="buf/trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.remaining" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#538-540">source</a><a href="#method.remaining" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#tymethod.remaining" class="fnname">remaining</a>(&self) -> usize</h4></section></summary><div class='docblock'>Returns the number of bytes between the current position and the end of |
| the buffer. <a href="buf/trait.Buf.html#tymethod.remaining">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chunk" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#543-545">source</a><a href="#method.chunk" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#tymethod.chunk" class="fnname">chunk</a>(&self) -> &[u8]</h4></section></summary><div class='docblock'>Returns a slice starting at the current position and of length between 0 |
| and <code>Buf::remaining()</code>. Note that this <em>can</em> return shorter slice (this allows |
| non-continuous internal representation). <a href="buf/trait.Buf.html#tymethod.chunk">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.advance" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#548-559">source</a><a href="#method.advance" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#tymethod.advance" class="fnname">advance</a>(&mut self, cnt: usize)</h4></section></summary><div class='docblock'>Advance the internal cursor of the Buf <a href="buf/trait.Buf.html#tymethod.advance">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.copy_to_bytes" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#561-569">source</a><a href="#method.copy_to_bytes" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.copy_to_bytes" class="fnname">copy_to_bytes</a>(&mut self, len: usize) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Consumes <code>len</code> bytes inside self and returns new instance of <code>Bytes</code> |
| with this data. <a href="buf/trait.Buf.html#method.copy_to_bytes">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chunks_vectored" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#164-175">source</a><a href="#method.chunks_vectored" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.chunks_vectored" class="fnname">chunks_vectored</a><'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize</h4></section></summary><div class='docblock'>Fills <code>dst</code> with potentially multiple slices starting at <code>self</code>’s |
| current position. <a href="buf/trait.Buf.html#method.chunks_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.has_remaining" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#226-228">source</a><a href="#method.has_remaining" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.has_remaining" class="fnname">has_remaining</a>(&self) -> bool</h4></section></summary><div class='docblock'>Returns true if there are any more bytes to consume <a href="buf/trait.Buf.html#method.has_remaining">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.copy_to_slice" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#251-270">source</a><a href="#method.copy_to_slice" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.copy_to_slice" class="fnname">copy_to_slice</a>(&mut self, dst: &mut [u8])</h4></section></summary><div class='docblock'>Copies bytes from <code>self</code> into <code>dst</code>. <a href="buf/trait.Buf.html#method.copy_to_slice">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u8" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#288-293">source</a><a href="#method.get_u8" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u8" class="fnname">get_u8</a>(&mut self) -> u8</h4></section></summary><div class='docblock'>Gets an unsigned 8 bit integer from <code>self</code>. <a href="buf/trait.Buf.html#method.get_u8">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i8" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#311-316">source</a><a href="#method.get_i8" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i8" class="fnname">get_i8</a>(&mut self) -> i8</h4></section></summary><div class='docblock'>Gets a signed 8 bit integer from <code>self</code>. <a href="buf/trait.Buf.html#method.get_i8">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u16" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#334-336">source</a><a href="#method.get_u16" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u16" class="fnname">get_u16</a>(&mut self) -> u16</h4></section></summary><div class='docblock'>Gets an unsigned 16 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_u16">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u16_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#354-356">source</a><a href="#method.get_u16_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u16_le" class="fnname">get_u16_le</a>(&mut self) -> u16</h4></section></summary><div class='docblock'>Gets an unsigned 16 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_u16_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u16_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#377-379">source</a><a href="#method.get_u16_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u16_ne" class="fnname">get_u16_ne</a>(&mut self) -> u16</h4></section></summary><div class='docblock'>Gets an unsigned 16 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_u16_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i16" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#397-399">source</a><a href="#method.get_i16" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i16" class="fnname">get_i16</a>(&mut self) -> i16</h4></section></summary><div class='docblock'>Gets a signed 16 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_i16">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i16_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#417-419">source</a><a href="#method.get_i16_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i16_le" class="fnname">get_i16_le</a>(&mut self) -> i16</h4></section></summary><div class='docblock'>Gets a signed 16 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_i16_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i16_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#440-442">source</a><a href="#method.get_i16_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i16_ne" class="fnname">get_i16_ne</a>(&mut self) -> i16</h4></section></summary><div class='docblock'>Gets a signed 16 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_i16_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u32" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#460-462">source</a><a href="#method.get_u32" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u32" class="fnname">get_u32</a>(&mut self) -> u32</h4></section></summary><div class='docblock'>Gets an unsigned 32 bit integer from <code>self</code> in the big-endian byte order. <a href="buf/trait.Buf.html#method.get_u32">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u32_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#480-482">source</a><a href="#method.get_u32_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u32_le" class="fnname">get_u32_le</a>(&mut self) -> u32</h4></section></summary><div class='docblock'>Gets an unsigned 32 bit integer from <code>self</code> in the little-endian byte order. <a href="buf/trait.Buf.html#method.get_u32_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u32_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#503-505">source</a><a href="#method.get_u32_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u32_ne" class="fnname">get_u32_ne</a>(&mut self) -> u32</h4></section></summary><div class='docblock'>Gets an unsigned 32 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_u32_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i32" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#523-525">source</a><a href="#method.get_i32" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i32" class="fnname">get_i32</a>(&mut self) -> i32</h4></section></summary><div class='docblock'>Gets a signed 32 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_i32">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i32_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#543-545">source</a><a href="#method.get_i32_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i32_le" class="fnname">get_i32_le</a>(&mut self) -> i32</h4></section></summary><div class='docblock'>Gets a signed 32 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_i32_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i32_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#566-568">source</a><a href="#method.get_i32_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i32_ne" class="fnname">get_i32_ne</a>(&mut self) -> i32</h4></section></summary><div class='docblock'>Gets a signed 32 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_i32_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u64" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#586-588">source</a><a href="#method.get_u64" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u64" class="fnname">get_u64</a>(&mut self) -> u64</h4></section></summary><div class='docblock'>Gets an unsigned 64 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_u64">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u64_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#606-608">source</a><a href="#method.get_u64_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u64_le" class="fnname">get_u64_le</a>(&mut self) -> u64</h4></section></summary><div class='docblock'>Gets an unsigned 64 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_u64_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u64_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#629-631">source</a><a href="#method.get_u64_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u64_ne" class="fnname">get_u64_ne</a>(&mut self) -> u64</h4></section></summary><div class='docblock'>Gets an unsigned 64 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_u64_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i64" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#649-651">source</a><a href="#method.get_i64" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i64" class="fnname">get_i64</a>(&mut self) -> i64</h4></section></summary><div class='docblock'>Gets a signed 64 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_i64">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i64_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#669-671">source</a><a href="#method.get_i64_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i64_le" class="fnname">get_i64_le</a>(&mut self) -> i64</h4></section></summary><div class='docblock'>Gets a signed 64 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_i64_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i64_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#692-694">source</a><a href="#method.get_i64_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i64_ne" class="fnname">get_i64_ne</a>(&mut self) -> i64</h4></section></summary><div class='docblock'>Gets a signed 64 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_i64_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u128" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#712-714">source</a><a href="#method.get_u128" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u128" class="fnname">get_u128</a>(&mut self) -> u128</h4></section></summary><div class='docblock'>Gets an unsigned 128 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_u128">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u128_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#732-734">source</a><a href="#method.get_u128_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u128_le" class="fnname">get_u128_le</a>(&mut self) -> u128</h4></section></summary><div class='docblock'>Gets an unsigned 128 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_u128_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_u128_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#755-757">source</a><a href="#method.get_u128_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_u128_ne" class="fnname">get_u128_ne</a>(&mut self) -> u128</h4></section></summary><div class='docblock'>Gets an unsigned 128 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_u128_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i128" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#775-777">source</a><a href="#method.get_i128" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i128" class="fnname">get_i128</a>(&mut self) -> i128</h4></section></summary><div class='docblock'>Gets a signed 128 bit integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_i128">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i128_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#795-797">source</a><a href="#method.get_i128_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i128_le" class="fnname">get_i128_le</a>(&mut self) -> i128</h4></section></summary><div class='docblock'>Gets a signed 128 bit integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_i128_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_i128_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#818-820">source</a><a href="#method.get_i128_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_i128_ne" class="fnname">get_i128_ne</a>(&mut self) -> i128</h4></section></summary><div class='docblock'>Gets a signed 128 bit integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_i128_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_uint" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#838-840">source</a><a href="#method.get_uint" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_uint" class="fnname">get_uint</a>(&mut self, nbytes: usize) -> u64</h4></section></summary><div class='docblock'>Gets an unsigned n-byte integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_uint">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_uint_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#858-860">source</a><a href="#method.get_uint_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_uint_le" class="fnname">get_uint_le</a>(&mut self, nbytes: usize) -> u64</h4></section></summary><div class='docblock'>Gets an unsigned n-byte integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_uint_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_uint_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#881-887">source</a><a href="#method.get_uint_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_uint_ne" class="fnname">get_uint_ne</a>(&mut self, nbytes: usize) -> u64</h4></section></summary><div class='docblock'>Gets an unsigned n-byte integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_uint_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_int" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#905-907">source</a><a href="#method.get_int" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_int" class="fnname">get_int</a>(&mut self, nbytes: usize) -> i64</h4></section></summary><div class='docblock'>Gets a signed n-byte integer from <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_int">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_int_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#925-927">source</a><a href="#method.get_int_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_int_le" class="fnname">get_int_le</a>(&mut self, nbytes: usize) -> i64</h4></section></summary><div class='docblock'>Gets a signed n-byte integer from <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_int_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_int_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#948-954">source</a><a href="#method.get_int_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_int_ne" class="fnname">get_int_ne</a>(&mut self, nbytes: usize) -> i64</h4></section></summary><div class='docblock'>Gets a signed n-byte integer from <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_int_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_f32" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#973-975">source</a><a href="#method.get_f32" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_f32" class="fnname">get_f32</a>(&mut self) -> f32</h4></section></summary><div class='docblock'>Gets an IEEE754 single-precision (4 bytes) floating point number from |
| <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_f32">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_f32_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#994-996">source</a><a href="#method.get_f32_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_f32_le" class="fnname">get_f32_le</a>(&mut self) -> f32</h4></section></summary><div class='docblock'>Gets an IEEE754 single-precision (4 bytes) floating point number from |
| <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_f32_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_f32_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1018-1020">source</a><a href="#method.get_f32_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_f32_ne" class="fnname">get_f32_ne</a>(&mut self) -> f32</h4></section></summary><div class='docblock'>Gets an IEEE754 single-precision (4 bytes) floating point number from |
| <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_f32_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_f64" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1039-1041">source</a><a href="#method.get_f64" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_f64" class="fnname">get_f64</a>(&mut self) -> f64</h4></section></summary><div class='docblock'>Gets an IEEE754 double-precision (8 bytes) floating point number from |
| <code>self</code> in big-endian byte order. <a href="buf/trait.Buf.html#method.get_f64">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_f64_le" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1060-1062">source</a><a href="#method.get_f64_le" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_f64_le" class="fnname">get_f64_le</a>(&mut self) -> f64</h4></section></summary><div class='docblock'>Gets an IEEE754 double-precision (8 bytes) floating point number from |
| <code>self</code> in little-endian byte order. <a href="buf/trait.Buf.html#method.get_f64_le">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_f64_ne" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1084-1086">source</a><a href="#method.get_f64_ne" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.get_f64_ne" class="fnname">get_f64_ne</a>(&mut self) -> f64</h4></section></summary><div class='docblock'>Gets an IEEE754 double-precision (8 bytes) floating point number from |
| <code>self</code> in native-endian byte order. <a href="buf/trait.Buf.html#method.get_f64_ne">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.take" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1134-1139">source</a><a href="#method.take" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.take" class="fnname">take</a>(self, limit: usize) -> <a class="struct" href="buf/struct.Take.html" title="struct bytes::buf::Take">Take</a><Self><span class="where fmt-newline">where<br> Self: Sized,</span></h4></section></summary><div class='docblock'>Creates an adaptor which will read at most <code>limit</code> bytes from <code>self</code>. <a href="buf/trait.Buf.html#method.take">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chain" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1156-1161">source</a><a href="#method.chain" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.chain" class="fnname">chain</a><U: <a class="trait" href="buf/trait.Buf.html" title="trait bytes::buf::Buf">Buf</a>>(self, next: U) -> <a class="struct" href="buf/struct.Chain.html" title="struct bytes::buf::Chain">Chain</a><Self, U><span class="where fmt-newline">where<br> Self: Sized,</span></h4></section></summary><div class='docblock'>Creates an adaptor which will chain this buffer with another. <a href="buf/trait.Buf.html#method.chain">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reader" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/buf/buf_impl.rs.html#1188-1193">source</a><a href="#method.reader" class="anchor"></a><h4 class="code-header">fn <a href="buf/trait.Buf.html#method.reader" class="fnname">reader</a>(self) -> <a class="struct" href="buf/struct.Reader.html" title="struct bytes::buf::Reader">Reader</a><Self><span class="where fmt-newline">where<br> Self: Sized,</span></h4></section></summary><div class='docblock'>Creates an adaptor which implements the <code>Read</code> trait for <code>self</code>. <a href="buf/trait.Buf.html#method.reader">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#529-534">source</a><a href="#impl-Clone-for-Bytes" class="anchor"></a><h3 class="code-header">impl Clone for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#531-533">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone</a>(&self) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clone_from</a>(&mut self, source: &Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/fmt/debug.rs.html#39-43">source</a><a href="#impl-Debug-for-Bytes" class="anchor"></a><h3 class="code-header">impl Debug for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/fmt/debug.rs.html#40-42">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, f: &mut Formatter<'_>) -> Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Default-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#789-794">source</a><a href="#impl-Default-for-Bytes" class="anchor"></a><h3 class="code-header">impl Default for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.default" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#791-793">source</a><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a class="fnname">default</a>() -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Deref-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#572-579">source</a><a href="#impl-Deref-for-Bytes" class="anchor"></a><h3 class="code-header">impl Deref for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Target" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Target" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Target</a> = [u8]</h4></section></summary><div class='docblock'>The resulting type after dereferencing.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#576-578">source</a><a href="#method.deref" class="anchor"></a><h4 class="code-header">fn <a class="fnname">deref</a>(&self) -> &[u8]</h4></section></summary><div class='docblock'>Dereferences the value.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Drop-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#522-527">source</a><a href="#impl-Drop-for-Bytes" class="anchor"></a><h3 class="code-header">impl Drop for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#524-526">source</a><a href="#method.drop" class="anchor"></a><h4 class="code-header">fn <a class="fnname">drop</a>(&mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Extend%3CBytes%3E-for-BytesMut" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1307-1316">source</a><a href="#impl-Extend%3CBytes%3E-for-BytesMut" class="anchor"></a><h3 class="code-header">impl Extend<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for <a class="struct" href="struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1308-1315">source</a><a href="#method.extend" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend</a><T>(&mut self, iter: T)<span class="where fmt-newline">where<br> T: IntoIterator<Item = <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>>,</span></h4></section></summary><div class='docblock'>Extends a collection with the contents of an iterator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend_one" class="method trait-impl has-srclink"><a href="#method.extend_one" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend_one</a>(&mut self, item: A)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>extend_one</code>)</span></div></span><div class='docblock'>Extends a collection with exactly one element.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend_reserve" class="method trait-impl has-srclink"><a href="#method.extend_reserve" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend_reserve</a>(&mut self, additional: usize)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>extend_one</code>)</span></div></span><div class='docblock'>Reserves capacity in a collection for the given number of additional elements. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3C%26%27static%20%5Bu8%5D%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#796-800">source</a><a href="#impl-From%3C%26%27static%20%5Bu8%5D%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl From<&'static [u8]> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#797-799">source</a><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(slice: &'static [u8]) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3C%26%27static%20str%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#802-806">source</a><a href="#impl-From%3C%26%27static%20str%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl From<&'static str> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#803-805">source</a><a href="#method.from-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(slice: &'static str) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CBox%3C%5Bu8%5D%2C%20Global%3E%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#843-872">source</a><a href="#impl-From%3CBox%3C%5Bu8%5D%2C%20Global%3E%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl From<Box<[u8], Global>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#844-871">source</a><a href="#method.from-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(slice: Box<[u8]>) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CBytes%3E-for-Vec%3Cu8%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#880-885">source</a><a href="#impl-From%3CBytes%3E-for-Vec%3Cu8%3E" class="anchor"></a><h3 class="code-header">impl From<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for Vec<u8></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#881-884">source</a><a href="#method.from-5" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(bytes: <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Vec<u8></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CBytesMut%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1182-1186">source</a><a href="#impl-From%3CBytesMut%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl From<<a class="struct" href="struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-6" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1183-1185">source</a><a href="#method.from-6" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(src: <a class="struct" href="struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a>) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CString%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#874-878">source</a><a href="#impl-From%3CString%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl From<String> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#875-877">source</a><a href="#method.from-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(s: String) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#808-841">source</a><a href="#impl-From%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl From<Vec<u8, Global>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#809-840">source</a><a href="#method.from-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(vec: Vec<u8>) -> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromIterator%3Cu8%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#621-625">source</a><a href="#impl-FromIterator%3Cu8%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl FromIterator<u8> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#622-624">source</a><a href="#method.from_iter" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from_iter</a><T: IntoIterator<Item = u8>>(into_iter: T) -> Self</h4></section></summary><div class='docblock'>Creates a value from an iterator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#588-595">source</a><a href="#impl-Hash-for-Bytes" class="anchor"></a><h3 class="code-header">impl Hash for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#589-594">source</a><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash</a><H>(&self, state: &mut H)<span class="where fmt-newline">where<br> H: Hasher,</span></h4></section></summary><div class='docblock'>Feeds this value into the given [<code>Hasher</code>]. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.3.0">1.3.0</span><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash_slice</a><H>(data: &[Self], state: &mut H)<span class="where fmt-newline">where<br> H: Hasher,</span></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given [<code>Hasher</code>]. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-%26%27a%20Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#612-619">source</a><a href="#impl-IntoIterator-for-%26%27a%20Bytes" class="anchor"></a><h3 class="code-header">impl<'a> IntoIterator for &'a <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Item</a> = &'a u8</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = Iter<'a, u8></h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#616-618">source</a><a href="#method.into_iter-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -> Self::IntoIter</h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#603-610">source</a><a href="#impl-IntoIterator-for-Bytes" class="anchor"></a><h3 class="code-header">impl IntoIterator for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Item</a> = u8</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = <a class="struct" href="buf/struct.IntoIter.html" title="struct bytes::buf::IntoIter">IntoIter</a><<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>></h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#607-609">source</a><a href="#method.into_iter" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -> Self::IntoIter</h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-LowerHex-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/fmt/hex.rs.html#34">source</a><a href="#impl-LowerHex-for-Bytes" class="anchor"></a><h3 class="code-header">impl LowerHex for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/fmt/hex.rs.html#34">source</a><a href="#method.fmt-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, f: &mut Formatter<'_>) -> Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Ord-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#641-645">source</a><a href="#impl-Ord-for-Bytes" class="anchor"></a><h3 class="code-header">impl Ord for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#642-644">source</a><a href="#method.cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Ordering</h4></section></summary><div class='docblock'>This method returns an [<code>Ordering</code>] between <code>self</code> and <code>other</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.21.0">1.21.0</span><a href="#method.max" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">max</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'>Compares and returns the maximum of two values. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.min" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.21.0">1.21.0</span><a href="#method.min" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">min</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'>Compares and returns the minimum of two values. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.50.0">1.50.0</span><a href="#method.clamp" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clamp</a>(self, min: Self, max: Self) -> Self<span class="where fmt-newline">where<br> Self: PartialOrd<Self>,</span></h4></section></summary><div class='docblock'>Restrict a value to a certain interval. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3C%26%27a%20T%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#769-776">source</a><a href="#impl-PartialEq%3C%26%27a%20T%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<'a, T: ?Sized> PartialEq<&'a T> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a><span class="where fmt-newline">where<br> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>: PartialEq<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-11" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#773-775">source</a><a href="#method.eq-11" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &&'a T) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-11" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-11" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3C%5Bu8%5D%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#649-653">source</a><a href="#impl-PartialEq%3C%5Bu8%5D%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialEq<[u8]> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#650-652">source</a><a href="#method.eq-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &[u8]) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-1" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-1" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-%26%5Bu8%5D" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#745-749">source</a><a href="#impl-PartialEq%3CBytes%3E-for-%26%5Bu8%5D" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for &[u8]</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-9" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#746-748">source</a><a href="#method.eq-9" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-9" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-9" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-%26str" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#757-761">source</a><a href="#impl-PartialEq%3CBytes%3E-for-%26str" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for &str</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-10" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#758-760">source</a><a href="#method.eq-10" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-10" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-10" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-%5Bu8%5D" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#661-665">source</a><a href="#impl-PartialEq%3CBytes%3E-for-%5Bu8%5D" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for [u8]</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#662-664">source</a><a href="#method.eq-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-2" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-2" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#629-633">source</a><a href="#impl-PartialEq%3CBytes%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#630-632">source</a><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-BytesMut" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1613-1617">source</a><a href="#impl-PartialEq%3CBytes%3E-for-BytesMut" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for <a class="struct" href="struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-13" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1614-1616">source</a><a href="#method.eq-13" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-13" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-13" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-String" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#733-737">source</a><a href="#impl-PartialEq%3CBytes%3E-for-String" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for String</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-8" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#734-736">source</a><a href="#method.eq-8" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-8" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-8" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-Vec%3Cu8%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#709-713">source</a><a href="#impl-PartialEq%3CBytes%3E-for-Vec%3Cu8%3E" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for Vec<u8></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-6" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#710-712">source</a><a href="#method.eq-6" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-6" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-6" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytes%3E-for-str" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#685-689">source</a><a href="#impl-PartialEq%3CBytes%3E-for-str" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for str</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#686-688">source</a><a href="#method.eq-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-4" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-4" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CBytesMut%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1607-1611">source</a><a href="#impl-PartialEq%3CBytesMut%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-12" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes_mut.rs.html#1608-1610">source</a><a href="#method.eq-12" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-12" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-12" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CString%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#721-725">source</a><a href="#impl-PartialEq%3CString%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialEq<String> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-7" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#722-724">source</a><a href="#method.eq-7" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &String) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-7" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-7" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#697-701">source</a><a href="#impl-PartialEq%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialEq<Vec<u8, Global>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#698-700">source</a><a href="#method.eq-5" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &Vec<u8>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-5" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-5" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3Cstr%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#673-677">source</a><a href="#impl-PartialEq%3Cstr%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialEq<str> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#674-676">source</a><a href="#method.eq-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &str) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne-3" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne-3" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3C%26%27a%20T%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#778-785">source</a><a href="#impl-PartialOrd%3C%26%27a%20T%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<'a, T: ?Sized> PartialOrd<&'a T> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a><span class="where fmt-newline">where<br> <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>: PartialOrd<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-11" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#782-784">source</a><a href="#method.partial_cmp-11" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &&'a T) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-11" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-11" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-11" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-11" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-11" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-11" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-11" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-11" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3C%5Bu8%5D%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#655-659">source</a><a href="#impl-PartialOrd%3C%5Bu8%5D%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialOrd<[u8]> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#656-658">source</a><a href="#method.partial_cmp-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &[u8]) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-1" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-1" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-1" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-1" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-1" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-1" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-1" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-1" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-%26%5Bu8%5D" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#751-755">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-%26%5Bu8%5D" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for &[u8]</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-9" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#752-754">source</a><a href="#method.partial_cmp-9" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-9" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-9" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-9" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-9" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-9" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-9" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-9" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-9" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-%26str" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#763-767">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-%26str" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for &str</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-10" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#764-766">source</a><a href="#method.partial_cmp-10" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-10" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-10" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-10" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-10" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-10" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-10" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-10" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-10" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-%5Bu8%5D" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#667-671">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-%5Bu8%5D" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for [u8]</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#668-670">source</a><a href="#method.partial_cmp-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-2" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-2" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-2" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-2" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-2" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-2" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-2" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-2" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#635-639">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#636-638">source</a><a href="#method.partial_cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-String" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#739-743">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-String" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for String</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-8" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#740-742">source</a><a href="#method.partial_cmp-8" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-8" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-8" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-8" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-8" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-8" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-8" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-8" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-8" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-Vec%3Cu8%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#715-719">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-Vec%3Cu8%3E" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for Vec<u8></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-6" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#716-718">source</a><a href="#method.partial_cmp-6" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-6" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-6" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-6" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-6" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-6" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-6" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-6" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-6" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CBytes%3E-for-str" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#691-695">source</a><a href="#impl-PartialOrd%3CBytes%3E-for-str" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>> for str</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#692-694">source</a><a href="#method.partial_cmp-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-4" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-4" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-4" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-4" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-4" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-4" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-4" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-4" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CString%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#727-731">source</a><a href="#impl-PartialOrd%3CString%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialOrd<String> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-7" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#728-730">source</a><a href="#method.partial_cmp-7" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &String) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-7" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-7" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-7" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-7" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-7" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-7" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-7" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-7" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#703-707">source</a><a href="#impl-PartialOrd%3CVec%3Cu8%2C%20Global%3E%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialOrd<Vec<u8, Global>> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#704-706">source</a><a href="#method.partial_cmp-5" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &Vec<u8>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-5" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-5" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-5" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-5" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-5" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-5" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-5" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-5" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3Cstr%3E-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#679-683">source</a><a href="#impl-PartialOrd%3Cstr%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl PartialOrd<str> for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#680-682">source</a><a href="#method.partial_cmp-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &str) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt-3" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt-3" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le-3" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le-3" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt-3" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt-3" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge-3" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge-3" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-UpperHex-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/fmt/hex.rs.html#36">source</a><a href="#impl-UpperHex-for-Bytes" class="anchor"></a><h3 class="code-header">impl UpperHex for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/bytes/fmt/hex.rs.html#36">source</a><a href="#method.fmt-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, f: &mut Formatter<'_>) -> Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter.</div></details></div></details><section id="impl-Eq-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#647">source</a><a href="#impl-Eq-for-Bytes" class="anchor"></a><h3 class="code-header">impl Eq for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section><section id="impl-Send-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#519">source</a><a href="#impl-Send-for-Bytes" class="anchor"></a><h3 class="code-header">impl Send for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section><section id="impl-Sync-for-Bytes" class="impl has-srclink"><a class="srclink rightside" href="../src/bytes/bytes.rs.html#520">source</a><a href="#impl-Sync-for-Bytes" class="anchor"></a><h3 class="code-header">impl Sync for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></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"><section id="impl-RefUnwindSafe-for-Bytes" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Bytes" class="anchor"></a><h3 class="code-header">impl RefUnwindSafe for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section><section id="impl-Unpin-for-Bytes" class="impl has-srclink"><a href="#impl-Unpin-for-Bytes" class="anchor"></a><h3 class="code-header">impl Unpin for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section><section id="impl-UnwindSafe-for-Bytes" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Bytes" class="anchor"></a><h3 class="code-header">impl UnwindSafe for <a class="struct" href="struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Bytes" class="impl has-srclink"><a href="#impl-Any-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T> Any for T<span class="where fmt-newline">where<br> T: 'static + ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a class="fnname">type_id</a>(&self) -> TypeId</h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Bytes" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T> Borrow<T> for T<span class="where fmt-newline">where<br> T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow-1" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow</a>(&self) -> &T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Bytes" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T> BorrowMut<T> for T<span class="where fmt-newline">where<br> T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow_mut</a>(&mut self) -> &mut T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Bytes" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T> From<T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-7" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.from-7" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Bytes" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T, U> Into<U> for T<span class="where fmt-newline">where<br> U: From<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> |
| <p>That is, this conversion is whatever the implementation of |
| <code>[From]<T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-Bytes" class="impl has-srclink"><a href="#impl-ToOwned-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T> ToOwned for T<span class="where fmt-newline">where<br> T: Clone,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a class="fnname">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone_into</a>(&self, target: &mut T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Bytes" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T, U> TryFrom<U> for T<span class="where fmt-newline">where<br> U: Into<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = Infallible</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(value: U) -> Result<T, <T as TryFrom<U>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Bytes" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-Bytes" class="anchor"></a><h3 class="code-header">impl<T, U> TryInto<U> for T<span class="where fmt-newline">where<br> U: TryFrom<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = <U as TryFrom<T>>::Error</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_into</a>(self) -> Result<U, <U as TryFrom<T>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="bytes" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |