35 lines
14 KiB
HTML
35 lines
14 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Concat` trait in crate `nom`."><meta name="keywords" content="rust, rustlang, rust-lang, Concat"><title>nom::lib::std::slice::Concat - Rust</title><link rel="stylesheet" type="text/css" href="../../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../../light.css" id="themeStyle"><script src="../../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../../noscript.css"></noscript><link rel="shortcut icon" href="../../../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../../nom/index.html'><div class='logo-container'><img src='../../../../rust-logo.png' alt='logo'></div></a><p class='location'>Trait Concat</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Output">Output</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.concat">concat</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-Concat%3CT%3E-for-%5BV%5D">[V]</a><a href="#impl-Concat%3Cstr%3E-for-%5BS%5D">[S]</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../../../index.html'>nom</a>::<wbr><a href='../../index.html'>lib</a>::<wbr><a href='../index.html'>std</a>::<wbr><a href='index.html'>slice</a></p><script>window.sidebarCurrent = {name: 'Concat', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../../../settings.html"><img src="../../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span class='since' title='Stable since Rust version '></span><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/slice.rs.html#623-631' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='../../../index.html'>nom</a>::<wbr><a href='../../index.html'>lib</a>::<wbr><a href='../index.html'>std</a>::<wbr><a href='index.html'>slice</a>::<wbr><a class="trait" href=''>Concat</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait Concat<Item> <span class="where fmt-newline">where<br> Item: ?<a class="trait" href="../../../../nom/lib/std/prelude/v1/v1/trait.Sized.html" title="trait nom::lib::std::prelude::v1::v1::Sized">Sized</a>, </span>{
|
||
type <a href='#associatedtype.Output' class="type">Output</a>;
|
||
fn <a href='#tymethod.concat' class='fnname'>concat</a>(slice: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> Self::<a class="type" href="../../../../nom/lib/std/slice/trait.Concat.html#associatedtype.Output" title="type nom::lib::std::slice::Concat::Output">Output</a>;
|
||
}</pre></div><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div><div class='docblock'><p>Helper trait for <a href="../../std/primitive.slice.html#method.concat"><code>[T]::concat</code></a>.</p>
|
||
<p>Note: the <code>Item</code> type parameter is not used in this trait,
|
||
but it allows impls to be more generic.
|
||
Without it, we get this error:</p>
|
||
<pre><code class="language-error">error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predica
|
||
--> src/liballoc/slice.rs:608:6
|
||
|
|
||
608 | impl<T: Clone, V: Borrow<[T]>> Concat for [V] {
|
||
| ^ unconstrained type parameter
|
||
</code></pre>
|
||
<p>This is because there could exist <code>V</code> types with multiple <code>Borrow<[_]></code> impls,
|
||
such that multiple <code>T</code> types would apply:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Foo</span>(<span class="ident">Vec</span><span class="op"><</span><span class="ident">u32</span><span class="op">></span>, <span class="ident">Vec</span><span class="op"><</span><span class="ident">String</span><span class="op">></span>);
|
||
|
||
<span class="kw">impl</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Borrow</span><span class="op"><</span>[<span class="ident">u32</span>]<span class="op">></span> <span class="kw">for</span> <span class="ident">Foo</span> {
|
||
<span class="kw">fn</span> <span class="ident">borrow</span>(<span class="kw-2">&</span><span class="self">self</span>) <span class="op">-</span><span class="op">></span> <span class="kw-2">&</span>[<span class="ident">u32</span>] { <span class="kw-2">&</span><span class="self">self</span>.<span class="number">0</span> }
|
||
}
|
||
|
||
<span class="kw">impl</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Borrow</span><span class="op"><</span>[<span class="ident">String</span>]<span class="op">></span> <span class="kw">for</span> <span class="ident">Foo</span> {
|
||
<span class="kw">fn</span> <span class="ident">borrow</span>(<span class="kw-2">&</span><span class="self">self</span>) <span class="op">-</span><span class="op">></span> <span class="kw-2">&</span>[<span class="ident">String</span>] { <span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span> }
|
||
}</pre></div>
|
||
</div>
|
||
<h2 id='associated-types' class='small-section-header'>Associated Types<a href='#associated-types' class='anchor'></a></h2><div class='methods'><h3 id='associatedtype.Output' class='method'><code id='Output.t'>type <a href='#associatedtype.Output' class="type">Output</a></code></h3><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div><div class='docblock'><p>The resulting type after concatenation</p>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.concat' class='method'><code id='concat.v'>fn <a href='#tymethod.concat' class='fnname'>concat</a>(slice: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> Self::<a class="type" href="../../../../nom/lib/std/slice/trait.Concat.html#associatedtype.Output" title="type nom::lib::std::slice::Concat::Output">Output</a></code></h3><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div><div class='docblock'><p>Implementation of <a href="../../std/primitive.slice.html#method.concat"><code>[T]::concat</code></a></p>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='foreign-impls' class='small-section-header'>Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a></h2><h3 id='impl-Concat%3CT%3E-for-%5BV%5D' class='impl'><code class='in-band'>impl<T, V> <a class="trait" href="../../../../nom/lib/std/slice/trait.Concat.html" title="trait nom::lib::std::slice::Concat">Concat</a><T> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../../../nom/lib/std/prelude/v1/v1/trait.Clone.html" title="trait nom::lib::std::prelude::v1::v1::Clone">Clone</a>,<br> V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a>T<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a href='#impl-Concat%3CT%3E-for-%5BV%5D' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/slice.rs.html#646-657' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Output-1' class="type"><code id='Output.t-1'>type <a href='#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../../../nom/lib/std/prelude/v1/v1/struct.Vec.html" title="struct nom::lib::std::prelude::v1::v1::Vec">Vec</a><T></code></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div><h4 id='method.concat' class="method hidden"><code id='concat.v-1'>fn <a href='#method.concat' class='fnname'>concat</a>(slice: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[V]</a>) -> <a class="struct" href="../../../../nom/lib/std/prelude/v1/v1/struct.Vec.html" title="struct nom::lib::std::prelude::v1::v1::Vec">Vec</a><T></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/slice.rs.html#649-656' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div></div><h3 id='impl-Concat%3Cstr%3E-for-%5BS%5D' class='impl'><code class='in-band'>impl<S> <a class="trait" href="../../../../nom/lib/std/slice/trait.Concat.html" title="trait nom::lib::std::slice::Concat">Concat</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a>S<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a> <span class="where fmt-newline">where<br> S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>, </span></code><a href='#impl-Concat%3Cstr%3E-for-%5BS%5D' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/str.rs.html#76-82' title='goto source code'>[src]</a></h3><div class='docblock'><p>Note: <code>str</code> in <code>Concat<str></code> is not meaningful here.
|
||
This type parameter of the trait only exists to enable another impl.</p>
|
||
</div><div class='impl-items'><h4 id='associatedtype.Output-2' class="type"><code id='Output.t-2'>type <a href='#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../../../nom/lib/std/prelude/v1/v1/struct.String.html" title="struct nom::lib::std::prelude::v1::v1::String">String</a></code></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div><h4 id='method.concat-1' class="method hidden"><code id='concat.v-2'>fn <a href='#method.concat' class='fnname'>concat</a>(slice: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[S]</a>) -> <a class="struct" href="../../../../nom/lib/std/prelude/v1/v1/struct.String.html" title="struct nom::lib::std::prelude::v1::v1::String">String</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/str.rs.html#79-81' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>slice_concat_trait</code>)</div></div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'></div><span class='loading-content'>Loading content...</span><script type="text/javascript" src="../../../../implementors/alloc/slice/trait.Concat.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../../";window.currentCrate = "nom";</script><script src="../../../../aliases.js"></script><script src="../../../../main.js"></script><script defer src="../../../../search-index.js"></script></body></html> |