mentat/serde_json/value/trait.Index.html
2018-08-22 17:04:13 +00:00

172 lines
No EOL
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 `Index` trait in crate `serde_json`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Index">
<title>serde_json::value::Index - 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="../../main.css" id="themeStyle">
<script src="../../storage.js"></script>
</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>
<p class='location'>Trait Index</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-Index">usize</a><a href="#impl-Index">str</a><a href="#impl-Index">String</a><a href="#impl-Index">&amp;&#39;a T</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../index.html'>serde_json</a>::<wbr><a href='index.html'>value</a></p><script>window.sidebarCurrent = {name: 'Index', 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 js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Trait <a href='../index.html'>serde_json</a>::<wbr><a href='index.html'>value</a>::<wbr><a class="trait" href=''>Index</a></span><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/serde_json/value/index.rs.html#47-62' title='goto source code'>[src]</a></span></h1>
<pre class='rust trait'>pub trait Index: Sealed { }</pre><div class='docblock'><p>A type that can be used to index into a <code>serde_json::Value</code>.</p>
<p>The <a href="../enum.Value.html#method.get"><code>get</code></a> and <a href="../enum.Value.html#method.get_mut"><code>get_mut</code></a> methods of <code>Value</code> accept any type that
implements <code>Index</code>, as does the <a href="../enum.Value.html#impl-Index%3CI%3E">square-bracket indexing operator</a>. This
trait is implemented for strings which are used as the index into a JSON
map, and for <code>usize</code> which is used as the index into a JSON array.</p>
<p>This trait is sealed and cannot be implemented for types outside of
<code>serde_json</code>.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="macro">json</span><span class="macro">!</span>({ <span class="string">&quot;inner&quot;</span>: [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>] });
<span class="comment">// Data is a JSON map so it can be indexed with a string.</span>
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">data</span>[<span class="string">&quot;inner&quot;</span>];
<span class="comment">// Inner is a JSON array so it can be indexed with an integer.</span>
<span class="kw">let</span> <span class="ident">first</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">inner</span>[<span class="number">0</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">first</span>, <span class="number">1</span>);</pre>
</div>
<h2 id='foreign-impls' class='small-section-header'>
Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
</h2>
<h3 id='impl-Index' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../serde_json/value/trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a href='#impl-Index' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#64-91' title='goto source code'>[src]</a></span></h3>
<span class='docblock autohide'><div class='impl-items'><h4 id='method.index_into' class="method"><span id='index_into.v' class='invisible'><code>fn <a href='#method.index_into' class='fnname'>index_into</a>&lt;'v&gt;(&amp;self, v: &amp;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#65-70' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_into_mut' class="method"><span id='index_into_mut.v' class='invisible'><code>fn <a href='#method.index_into_mut' class='fnname'>index_into_mut</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#71-76' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_or_insert' class="method"><span id='index_or_insert.v' class='invisible'><code>fn <a href='#method.index_or_insert' class='fnname'>index_or_insert</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>) -&gt; &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#77-90' title='goto source code'>[src]</a></span></h4>
</div></span><h3 id='impl-Index-1' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../serde_json/value/trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a href='#impl-Index-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#93-115' title='goto source code'>[src]</a></span></h3>
<span class='docblock autohide'><div class='impl-items'><h4 id='method.index_into-1' class="method"><span id='index_into.v-1' class='invisible'><code>fn <a href='#method.index_into' class='fnname'>index_into</a>&lt;'v&gt;(&amp;self, v: &amp;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#94-99' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_into_mut-1' class="method"><span id='index_into_mut.v-1' class='invisible'><code>fn <a href='#method.index_into_mut' class='fnname'>index_into_mut</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#100-105' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_or_insert-1' class="method"><span id='index_or_insert.v-1' class='invisible'><code>fn <a href='#method.index_or_insert' class='fnname'>index_or_insert</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>) -&gt; &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#106-114' title='goto source code'>[src]</a></span></h4>
</div></span><h3 id='impl-Index-2' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../serde_json/value/trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a href='#impl-Index-2' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#117-127' title='goto source code'>[src]</a></span></h3>
<span class='docblock autohide'><div class='impl-items'><h4 id='method.index_into-2' class="method"><span id='index_into.v-2' class='invisible'><code>fn <a href='#method.index_into' class='fnname'>index_into</a>&lt;'v&gt;(&amp;self, v: &amp;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#118-120' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_into_mut-2' class="method"><span id='index_into_mut.v-2' class='invisible'><code>fn <a href='#method.index_into_mut' class='fnname'>index_into_mut</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#121-123' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_or_insert-2' class="method"><span id='index_or_insert.v-2' class='invisible'><code>fn <a href='#method.index_or_insert' class='fnname'>index_or_insert</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>) -&gt; &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#124-126' title='goto source code'>[src]</a></span></h4>
</div></span><h3 id='impl-Index-3' class='impl'><span class='in-band'><code>impl&lt;'a, T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="../../serde_json/value/trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a </a>T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../serde_json/value/trait.Index.html" title="trait serde_json::value::Index">Index</a>,&nbsp;</span></code><a href='#impl-Index-3' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#129-142' title='goto source code'>[src]</a></span></h3>
<span class='docblock autohide'><div class='impl-items'><h4 id='method.index_into-3' class="method"><span id='index_into.v-3' class='invisible'><code>fn <a href='#method.index_into' class='fnname'>index_into</a>&lt;'v&gt;(&amp;self, v: &amp;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#133-135' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_into_mut-3' class="method"><span id='index_into_mut.v-3' class='invisible'><code>fn <a href='#method.index_into_mut' class='fnname'>index_into_mut</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</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;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#136-138' title='goto source code'>[src]</a></span></h4>
<h4 id='method.index_or_insert-3' class="method"><span id='index_or_insert.v-3' class='invisible'><code>fn <a href='#method.index_or_insert' class='fnname'>index_or_insert</a>&lt;'v&gt;(&amp;self, v: &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a>) -&gt; &amp;'v mut <a class="enum" href="../../serde_json/value/enum.Value.html" title="enum serde_json::value::Value">Value</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/serde_json/value/index.rs.html#139-141' title='goto source code'>[src]</a></span></h4>
</div></span>
<h2 id='implementors' class='small-section-header'>
Implementors<a href='#implementors' class='anchor'></a>
</h2>
<ul class='item-list' id='implementors-list'>
</ul><script type="text/javascript" async
src="../../implementors/serde_json/value/trait.Index.js">
</script></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd></kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd></kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd></kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "serde_json";
</script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>