Files
rust-gpu/api/raw_string/trait.RawStrIndex.html
2020-11-10 09:43:22 +00:00

36 lines
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `RawStrIndex` trait in crate `raw_string`."><meta name="keywords" content="rust, rustlang, rust-lang, RawStrIndex"><title>raw_string::RawStrIndex - 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="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><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">&#9776;</div><a href='../raw_string/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait RawStrIndex</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.get">get</a><a href="#tymethod.get_mut">get_mut</a><a href="#tymethod.get_unchecked">get_unchecked</a><a href="#tymethod.get_unchecked_mut">get_unchecked_mut</a><a href="#tymethod.index">index</a><a href="#tymethod.index_mut">index_mut</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">raw_string</a></p><script>window.sidebarCurrent = {name: "RawStrIndex", 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!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></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><span class="help-button">?</span>
<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 id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../src/raw_string/str/index.rs.html#29-44" title="goto source code">[src]</a></span><span class="in-band">Trait <a href="index.html">raw_string</a>::<wbr><a class="trait" href="">RawStrIndex</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait RawStrIndex {
type <a href="#associatedtype.Output" class="type">Output</a>: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>;
fn <a href="#tymethod.get" class="fnname">get</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;;
<div class="item-spacer"></div> fn <a href="#tymethod.get_mut" class="fnname">get_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;;
<div class="item-spacer"></div> unsafe fn <a href="#tymethod.get_unchecked" class="fnname">get_unchecked</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
<div class="item-spacer"></div> unsafe fn <a href="#tymethod.get_unchecked_mut" class="fnname">get_unchecked_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
<div class="item-spacer"></div> fn <a href="#tymethod.index" class="fnname">index</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
<div class="item-spacer"></div> fn <a href="#tymethod.index_mut" class="fnname">index_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
}</pre></div><div class="docblock"><p>The equivalent of <code>SliceIndex</code> for <code>RawStr</code>.</p>
<h1 id="usage" class="section-header"><a href="#usage">Usage</a></h1>
<p>Normally, this trait is not used directly.
Its functionality is exposed through <code>Index</code> and the <code>get</code> methods of <code>RawStr</code>.</p>
<h1 id="implementors-1" class="section-header"><a href="#implementors-1">Implementors</a></h1>
<p><code>RawStrIndex</code> is automatically implemented for all that implement <code>SliceIndex&lt;[u8]&gt;</code>:</p>
<ul>
<li>a <code>SliceIndex&lt;[u8], Output=[u8]&gt;</code> automatically implements <code>RawStrIndex&lt;Output=RawStr&gt;</code>, and</li>
<li>a <code>SliceIndex&lt;[u8], Output=u8&gt;</code> automatically implements <code>RawStrIndex&lt;Output=u8&gt;</code>.</li>
</ul>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">RawStr</span>::<span class="ident">from_str</span>(<span class="string">&quot;hello world&quot;</span>);
<span class="kw">let</span> <span class="ident">hello</span>: <span class="kw-2">&amp;</span><span class="ident">RawStr</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">s</span>[..<span class="number">5</span>]; <span class="comment">// This is a slice.</span>
<span class="kw">let</span> <span class="ident">space</span>: <span class="ident">u8</span> <span class="op">=</span> <span class="ident">s</span>[<span class="number">5</span>]; <span class="comment">// This is a single byte</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">hello</span>, <span class="string">&quot;hello&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">space</span>, <span class="string">b&#39; &#39;</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>type <a href="#associatedtype.Output" class="type">Output</a>: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></code></h3><div class="docblock"><p><code>RawStr</code> (for ranges) or <code>u8</code> (for single indexes).</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.get" class="method"><code>fn <a href="#tymethod.get" class="fnname">get</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;</code></h3><div class="docblock"><p>Get the range or byte from the given <code>&amp;RawStr</code>.</p>
</div><h3 id="tymethod.get_mut" class="method"><code>fn <a href="#tymethod.get_mut" class="fnname">get_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;</code></h3><div class="docblock"><p>Get the (mutable) range or byte from the given <code>&amp;mut RawStr</code>.</p>
</div><h3 id="tymethod.get_unchecked" class="method"><code>unsafe fn <a href="#tymethod.get_unchecked" class="fnname">get_unchecked</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code></h3><div class="docblock"><p>Like <code>get</code>, but unsafe and unchecked.</p>
</div><h3 id="tymethod.get_unchecked_mut" class="method"><code>unsafe fn <a href="#tymethod.get_unchecked_mut" class="fnname">get_unchecked_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code></h3><div class="docblock"><p>Like <code>get_mut</code>, but unsafe and unchecked.</p>
</div><h3 id="tymethod.index" class="method"><code>fn <a href="#tymethod.index" class="fnname">index</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code></h3><div class="docblock"><p>Like <code>get</code>, but panics on failure.</p>
</div><h3 id="tymethod.index_mut" class="method"><code>fn <a href="#tymethod.index_mut" class="fnname">index_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code></h3><div class="docblock"><p>Like <code>get_mut</code>, but panics on failure.</p>
</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"><h3 id="impl-RawStrIndex" class="impl"><code class="in-band">impl&lt;I&gt; RawStrIndex for I <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/slice/index/trait.SliceIndex.html" title="trait core::slice::index::SliceIndex">SliceIndex</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/slice/index/trait.SliceIndex.html#associatedtype.Output" title="type core::slice::index::SliceIndex::Output">Output</a>: RawStrIndexOutput + 'static,&nbsp;</span></code><a href="#impl-RawStrIndex" class="anchor"></a><a class="srclink" href="../src/raw_string/str/index.rs.html#77-109" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-1" class="type"><code>type <a href="#associatedtype.Output-1" class="type">Output</a> = &lt;&lt;I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/slice/index/trait.SliceIndex.html" title="trait core::slice::index::SliceIndex">SliceIndex</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/slice/index/trait.SliceIndex.html#associatedtype.Output" title="type core::slice::index::SliceIndex::Output">Output</a> as RawStrIndexOutput&gt;::Output</code></h4><h4 id="method.get" class="method hidden"><code>fn <a href="#method.get" class="fnname">get</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;</code><a class="srclink" href="../src/raw_string/str/index.rs.html#84-86" title="goto source code">[src]</a></h4><h4 id="method.get_mut" class="method hidden"><code>fn <a href="#method.get_mut" class="fnname">get_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;</code><a class="srclink" href="../src/raw_string/str/index.rs.html#88-92" title="goto source code">[src]</a></h4><h4 id="method.get_unchecked" class="method hidden"><code>unsafe fn <a href="#method.get_unchecked" class="fnname">get_unchecked</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code><a class="srclink" href="../src/raw_string/str/index.rs.html#94-96" title="goto source code">[src]</a></h4><h4 id="method.get_unchecked_mut" class="method hidden"><code>unsafe fn <a href="#method.get_unchecked_mut" class="fnname">get_unchecked_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code><a class="srclink" href="../src/raw_string/str/index.rs.html#98-100" title="goto source code">[src]</a></h4><h4 id="method.index" class="method hidden"><code>fn <a href="#method.index" class="fnname">index</a>(self, s: &amp;<a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code><a class="srclink" href="../src/raw_string/str/index.rs.html#102-104" title="goto source code">[src]</a></h4><h4 id="method.index_mut" class="method hidden"><code>fn <a href="#method.index_mut" class="fnname">index_mut</a>(self, s: &amp;mut <a class="struct" href="../raw_string/struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="type" href="../raw_string/trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></code><a class="srclink" href="../src/raw_string/str/index.rs.html#106-108" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../implementors/raw_string/trait.RawStrIndex.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "raw_string";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>