Files
rust-gpu/api/raw_string/trait.RawStrIndex.html
2026-04-13 16:52:47 +00:00

35 lines
15 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="The equivalent of `SliceIndex` for `RawStr`."><title>RawStrIndex in raw_string - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-17e0aaed.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="raw_string" data-themes="" data-resource-suffix="" data-rustdoc-version="1.96.0-nightly (02c7f9bec 2026-04-10)" data-channel="nightly" data-search-js="search-b5634cc7.js" data-stringdex-js="stringdex-2da4960a.js" data-settings-js="settings-170eb4bf.js" ><script src="../static.files/storage-41dd4d93.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5013f961.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-f7c3ffd8.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><a class="skip-main-content" href="#main-content">Skip to main content</a><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">RawStrIndex</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../raw_string/index.html">raw_<wbr>string</a><span class="version">0.3.5</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">RawStr<wbr>Index</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#usage" title="Usage">Usage</a></li><li><a href="#implementors-1" title="Implementors">Implementors</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Output" title="Output">Output</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.get" title="get">get</a></li><li><a href="#tymethod.get_mut" title="get_mut">get_mut</a></li><li><a href="#tymethod.get_unchecked" title="get_unchecked">get_unchecked</a></li><li><a href="#tymethod.get_unchecked_mut" title="get_unchecked_mut">get_unchecked_mut</a></li><li><a href="#tymethod.index" title="index">index</a></li><li><a href="#tymethod.index_mut" title="index_mut">index_mut</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate raw_<wbr>string</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content" tabindex="-1"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">raw_string</a></div><h1>Trait <span class="trait">RawStr<wbr>Index</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/raw_string/str/index.rs.html#29-44">Source</a> </span></div><pre class="rust item-decl"><code>pub trait RawStrIndex {
type <a href="#associatedtype.Output" class="associatedtype">Output</a>: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>;
// Required methods
fn <a href="#tymethod.get" class="fn">get</a>(self, s: &amp;<a class="struct" href="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="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.get_mut" class="fn">get_mut</a>(self, s: &amp;mut <a class="struct" href="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="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.get_unchecked" class="fn">get_unchecked</a>(self, s: &amp;<a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.get_unchecked_mut" class="fn">get_unchecked_mut</a>(self, s: &amp;mut <a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.index" class="fn">index</a>(self, s: &amp;<a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.index_mut" class="fn">index_mut</a>(self, s: &amp;mut <a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The equivalent of <code>SliceIndex</code> for <code>RawStr</code>.</p>
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
<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>
<h2 id="implementors-1"><a class="doc-anchor" href="#implementors-1">§</a>Implementors</h2>
<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>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>s = RawStr::from_str(<span class="string">"hello world"</span>);
<span class="kw">let </span>hello: <span class="kw-2">&amp;</span>RawStr = <span class="kw-2">&amp;</span>s[..<span class="number">5</span>]; <span class="comment">// This is a slice.
</span><span class="kw">let </span>space: u8 = s[<span class="number">5</span>]; <span class="comment">// This is a single byte
</span><span class="macro">assert_eq!</span>(hello, <span class="string">"hello"</span>);
<span class="macro">assert_eq!</span>(space, <span class="string">b' '</span>);</code></pre></div></div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Output" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#31">Source</a><h4 class="code-header">type <a href="#associatedtype.Output" class="associatedtype">Output</a>: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></h4></section></summary><div class="docblock"><p><code>RawStr</code> (for ranges) or <code>u8</code> (for single indexes).</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.get" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#33">Source</a><h4 class="code-header">fn <a href="#tymethod.get" class="fn">get</a>(self, s: &amp;<a class="struct" href="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="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;</h4></section></summary><div class="docblock"><p>Get the range or byte from the given <code>&amp;RawStr</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_mut" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#35">Source</a><h4 class="code-header">fn <a href="#tymethod.get_mut" class="fn">get_mut</a>(self, s: &amp;mut <a class="struct" href="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="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a>&gt;</h4></section></summary><div class="docblock"><p>Get the (mutable) range or byte from the given <code>&amp;mut RawStr</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_unchecked" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#37">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.get_unchecked" class="fn">get_unchecked</a>(self, s: &amp;<a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></h4></section></summary><div class="docblock"><p>Like <code>get</code>, but unsafe and unchecked.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_unchecked_mut" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#39">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.get_unchecked_mut" class="fn">get_unchecked_mut</a>(self, s: &amp;mut <a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></h4></section></summary><div class="docblock"><p>Like <code>get_mut</code>, but unsafe and unchecked.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.index" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#41">Source</a><h4 class="code-header">fn <a href="#tymethod.index" class="fn">index</a>(self, s: &amp;<a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></h4></section></summary><div class="docblock"><p>Like <code>get</code>, but panics on failure.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.index_mut" class="method"><a class="src rightside" href="../src/raw_string/str/index.rs.html#43">Source</a><h4 class="code-header">fn <a href="#tymethod.index_mut" class="fn">index_mut</a>(self, s: &amp;mut <a class="struct" href="struct.RawStr.html" title="struct raw_string::RawStr">RawStr</a>) -&gt; &amp;mut Self::<a class="associatedtype" href="trait.RawStrIndex.html#associatedtype.Output" title="type raw_string::RawStrIndex::Output">Output</a></h4></section></summary><div class="docblock"><p>Like <code>get_mut</code>, but panics on failure.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><div class="negative-marker"></div><details class="toggle implementors-toggle"><summary><section id="impl-RawStrIndex-for-I" class="impl"><a class="src rightside" href="../src/raw_string/str/index.rs.html#77-109">Source</a><a href="#impl-RawStrIndex-for-I" class="anchor">§</a><h3 class="code-header">impl&lt;I&gt; <a class="trait" href="trait.RawStrIndex.html" title="trait raw_string::RawStrIndex">RawStrIndex</a> for I<div class="where">where
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.u8.html">u8</a>]&gt;,
I::<a class="associatedtype" 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,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Output-1" class="associatedtype trait-impl"><a class="src rightside" href="../src/raw_string/str/index.rs.html#82">Source</a><a href="#associatedtype.Output-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Output" class="associatedtype">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.u8.html">u8</a>]&gt;&gt;::<a class="associatedtype" 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</h4></section></div></details></div><script src="../trait.impl/raw_string/str/index/trait.RawStrIndex.js" async></script></section></div></main></body></html>