wasmer/rustdoc/clap/struct.ArgMatches.html

489 lines
91 KiB
HTML
Raw Permalink Normal View History

2019-09-06 15:57:44 -07:00
<!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 `ArgMatches` struct in crate `clap`."><meta name="keywords" content="rust, rustlang, rust-lang, ArgMatches"><title>clap::ArgMatches - 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 struct"><!--[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='../clap/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Struct ArgMatches</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.index_of">index_of</a><a href="#method.indices_of">indices_of</a><a href="#method.is_present">is_present</a><a href="#method.occurrences_of">occurrences_of</a><a href="#method.subcommand">subcommand</a><a href="#method.subcommand_matches">subcommand_matches</a><a href="#method.subcommand_name">subcommand_name</a><a href="#method.usage">usage</a><a href="#method.value_of">value_of</a><a href="#method.value_of_lossy">value_of_lossy</a><a href="#method.value_of_os">value_of_os</a><a href="#method.values_of">values_of</a><a href="#method.values_of_lossy">values_of_lossy</a><a href="#method.values_of_os">values_of_os</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a></div></div><p class='location'><a href='index.html'>clap</a></p><script>window.sidebarCurrent = {name: 'ArgMatches', ty: 'struct', 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"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" 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 id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse
the user. New instances of this struct are obtained by using the <a href="./struct.App.html#method.get_matches"><code>App::get_matches</code></a> family of
methods.</p>
<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">matches</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;MyApp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;out&quot;</span>)
.<span class="ident">long</span>(<span class="string">&quot;output&quot;</span>)
.<span class="ident">required</span>(<span class="bool-val">true</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;d&quot;</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;cfg&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;c&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches</span>(); <span class="comment">// builds the instance of ArgMatches</span>
<span class="comment">// to get information about the &quot;cfg&quot; argument we created, such as the value supplied we use</span>
<span class="comment">// various ArgMatches methods, such as ArgMatches::value_of</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">c</span>) <span class="op">=</span> <span class="ident">matches</span>.<span class="ident">value_of</span>(<span class="string">&quot;cfg&quot;</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Value for -c: {}&quot;</span>, <span class="ident">c</span>);
}
<span class="comment">// The ArgMatches::value_of method returns an Option because the user may not have supplied</span>
<span class="comment">// that argument at runtime. But if we specified that the argument was &quot;required&quot; as we did</span>
<span class="comment">// with the &quot;out&quot; argument, we can safely unwrap because `clap` verifies that was actually</span>
<span class="comment">// used at runtime.</span>
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Value for --output: {}&quot;</span>, <span class="ident">matches</span>.<span class="ident">value_of</span>(<span class="string">&quot;out&quot;</span>).<span class="ident">unwrap</span>());
<span class="comment">// You can check the presence of an argument</span>
<span class="kw">if</span> <span class="ident">matches</span>.<span class="ident">is_present</span>(<span class="string">&quot;out&quot;</span>) {
<span class="comment">// Another way to check if an argument was present, or if it occurred multiple times is to</span>
<span class="comment">// use occurrences_of() which returns 0 if an argument isn&#39;t found at runtime, or the</span>
<span class="comment">// number of times that it occurred, if it was. To allow an argument to appear more than</span>
<span class="comment">// once, you must use the .multiple(true) method, otherwise it will only return 1 or 0.</span>
<span class="kw">if</span> <span class="ident">matches</span>.<span class="ident">occurrences_of</span>(<span class="string">&quot;debug&quot;</span>) <span class="op">&gt;</span> <span class="number">2</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Debug mode is REALLY on, don&#39;t be crazy&quot;</span>);
} <span class="kw">else</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Debug mode kind of on&quot;</span>);
}
}</pre></div>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl' class='anchor'></a><a class='srclink' href='../src/clap/args/arg_matches.rs.html#77-760' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.value_of' class="method"><code id='value_of.v'>pub fn <a href='#method.value_of' class='fnname'>value_of</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;self, name: S) -&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;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#112-119' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets the value of a specific <a href="./struct.Arg.html#method.takes_value">option</a> or <a href="./struct.Arg.html#method.index">positional</a> argument (i.e. an argument that takes
an additional value at runtime). If the option wasn't present at runtime
it returns <code>None</code>.</p>
<p><em>NOTE:</em> If getting a value for an option or positional argument that allows multiples,
prefer <a href="./struct.ArgMatches.html#method.values_of"><code>ArgMatches::values_of</code></a> as <code>ArgMatches::value_of</code> will only return the <em>first</em>
value.</p>
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
<p>This method will <a href="https://doc.rust-lang.org/std/macro.panic!.html"><code>panic!</code></a> if the value contains invalid UTF-8 code points.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;output&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;something&quot;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">value_of</span>(<span class="string">&quot;output&quot;</span>), <span class="prelude-val">Some</span>(<span class="string">&quot;something&quot;</span>));</pre></div>
</div><h4 id='method.value_of_lossy' class="method"><code id='value_of_lossy.v'>pub fn <a href='#method.value_of_lossy' class='fnname'>value_of_lossy</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;'a self, name: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#144-151' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets the lossy value of a specific argument. If the argument wasn't present at runtime
it returns <code>None</code>. A lossy value is one which contains invalid UTF-8 code points, those
invalid points will be replaced with <code>\u{FFFD}</code></p>
<p><em>NOTE:</em> If getting a value for an option or positional argument that allows multiples,
prefer <a href="./struct.ArgMatches.html#method.values_of_lossy"><code>Arg::values_of_lossy</code></a> as <code>value_of_lossy()</code> will only return the <em>first</em> value.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">OsString</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">unix</span>::<span class="ident">ffi</span>::{<span class="ident">OsStrExt</span>,<span class="ident">OsStringExt</span>};
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;utf8&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">from_usage</span>(<span class="string">&quot;&lt;arg&gt; &#39;some arg&#39;&quot;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">OsString</span>::<span class="ident">from</span>(<span class="string">&quot;myprog&quot;</span>),
<span class="comment">// &quot;Hi {0xe9}!&quot;</span>
<span class="ident">OsString</span>::<span class="ident">from_vec</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">b&#39;H&#39;</span>, <span class="string">b&#39;i&#39;</span>, <span class="string">b&#39; &#39;</span>, <span class="number">0xe9</span>, <span class="string">b&#39;!&#39;</span>])]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="kw-2">*</span><span class="ident">m</span>.<span class="ident">value_of_lossy</span>(<span class="string">&quot;arg&quot;</span>).<span class="ident">unwrap</span>(), <span class="string">&quot;Hi \u{FFFD}!&quot;</span>);</pre></div>
</div><h4 id='method.value_of_os' class="method"><code id='value_of_os.v'>pub fn <a href='#method.value_of_os' class='fnname'>value_of_os</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;self, name: S) -&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;<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#180-184' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets the OS version of a string value of a specific argument. If the option wasn't present
at runtime it returns <code>None</code>. An OS value on Unix-like systems is any series of bytes,
regardless of whether or not they contain valid UTF-8 code points. Since <a href="https://doc.rust-lang.org/std/string/struct.String.html"><code>String</code></a>s in
Rust are guaranteed to be valid UTF-8, a valid filename on a Unix system as an argument
value may contain invalid UTF-8 code points.</p>
<p><em>NOTE:</em> If getting a value for an option or positional argument that allows multiples,
prefer <a href="./struct.ArgMatches.html#method.values_of_os"><code>ArgMatches::values_of_os</code></a> as <code>Arg::value_of_os</code> will only return the <em>first</em>
value.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">OsString</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">unix</span>::<span class="ident">ffi</span>::{<span class="ident">OsStrExt</span>,<span class="ident">OsStringExt</span>};
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;utf8&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">from_usage</span>(<span class="string">&quot;&lt;arg&gt; &#39;some arg&#39;&quot;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">OsString</span>::<span class="ident">from</span>(<span class="string">&quot;myprog&quot;</span>),
<span class="comment">// &quot;Hi {0xe9}!&quot;</span>
<span class="ident">OsString</span>::<span class="ident">from_vec</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">b&#39;H&#39;</span>, <span class="string">b&#39;i&#39;</span>, <span class="string">b&#39; &#39;</span>, <span class="number">0xe9</span>, <span class="string">b&#39;!&#39;</span>])]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="kw-2">*</span><span class="ident">m</span>.<span class="ident">value_of_os</span>(<span class="string">&quot;arg&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), [<span class="string">b&#39;H&#39;</span>, <span class="string">b&#39;i&#39;</span>, <span class="string">b&#39; &#39;</span>, <span class="number">0xe9</span>, <span class="string">b&#39;!&#39;</span>]);</pre></div>
</div><h4 id='method.values_of' class="method"><code id='values_of.v'>pub fn <a href='#method.values_of' class='fnname'>values_of</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;'a self, name: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../clap/struct.Values.html" title="struct clap::Values">Values</a>&lt;'a&gt;&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#211-220' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets a <a href="./struct.Values.html"><code>Values</code></a> struct which implements <a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html"><code>Iterator</code></a> for values of a specific argument
(i.e. an argument that takes multiple values at runtime). If the option wasn't present at
runtime it returns <code>None</code></p>
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
<p>This method will panic if any of the values contain invalid UTF-8 code points.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;output&quot;</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-o&quot;</span>, <span class="string">&quot;val1&quot;</span>, <span class="string">&quot;val2&quot;</span>, <span class="string">&quot;val3&quot;</span>
]);
<span class="kw">let</span> <span class="ident">vals</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">m</span>.<span class="ident">values_of</span>(<span class="string">&quot;output&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vals</span>, [<span class="string">&quot;val1&quot;</span>, <span class="string">&quot;val2&quot;</span>, <span class="string">&quot;val3&quot;</span>]);</pre></div>
</div><h4 id='method.values_of_lossy' class="method"><code id='values_of_lossy.v'>pub fn <a href='#method.values_of_lossy' class='fnname'>values_of_lossy</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;'a self, name: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#246-256' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets the lossy values of a specific argument. If the option wasn't present at runtime
it returns <code>None</code>. A lossy value is one where if it contains invalid UTF-8 code points,
those invalid points will be replaced with <code>\u{FFFD}</code></p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::<span class="ident">OsString</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">unix</span>::<span class="ident">ffi</span>::<span class="ident">OsStringExt</span>;
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;utf8&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">from_usage</span>(<span class="string">&quot;&lt;arg&gt;... &#39;some arg&#39;&quot;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">OsString</span>::<span class="ident">from</span>(<span class="string">&quot;myprog&quot;</span>),
<span class="comment">// &quot;Hi&quot;</span>
<span class="ident">OsString</span>::<span class="ident">from_vec</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">b&#39;H&#39;</span>, <span class="string">b&#39;i&#39;</span>]),
<span class="comment">// &quot;{0xe9}!&quot;</span>
<span class="ident">OsString</span>::<span class="ident">from_vec</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0xe9</span>, <span class="string">b&#39;!&#39;</span>])]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">itr</span> <span class="op">=</span> <span class="ident">m</span>.<span class="ident">values_of_lossy</span>(<span class="string">&quot;arg&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">into_iter</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="ident">itr</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>()[..], <span class="string">&quot;Hi&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="ident">itr</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>()[..], <span class="string">&quot;\u{FFFD}!&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);</pre></div>
</div><h4 id='method.values_of_os' class="method"><code id='values_of_os.v'>pub fn <a href='#method.values_of_os' class='fnname'>values_of_os</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;'a self, name: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../clap/struct.OsValues.html" title="struct clap::OsValues">OsValues</a>&lt;'a&gt;&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#289-298' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets a <a href="./struct.OsValues.html"><code>OsValues</code></a> struct which is implements <a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html"><code>Iterator</code></a> for <a href="https://doc.rust-lang.org/std/ffi/struct.OsString.html"><code>OsString</code></a> values of a
specific argument. If the option wasn't present at runtime it returns <code>None</code>. An OS value
on Unix-like systems is any series of bytes, regardless of whether or not they contain
valid UTF-8 code points. Since <a href="https://doc.rust-lang.org/std/string/struct.String.html"><code>String</code></a>s in Rust are guaranteed to be valid UTF-8, a valid
filename as an argument value on Linux (for example) may contain invalid UTF-8 code points.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ffi</span>::{<span class="ident">OsStr</span>,<span class="ident">OsString</span>};
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">unix</span>::<span class="ident">ffi</span>::{<span class="ident">OsStrExt</span>,<span class="ident">OsStringExt</span>};
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;utf8&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">from_usage</span>(<span class="string">&quot;&lt;arg&gt;... &#39;some arg&#39;&quot;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">OsString</span>::<span class="ident">from</span>(<span class="string">&quot;myprog&quot;</span>),
<span class="comment">// &quot;Hi&quot;</span>
<span class="ident">OsString</span>::<span class="ident">from_vec</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">b&#39;H&#39;</span>, <span class="string">b&#39;i&#39;</span>]),
<span class="comment">// &quot;{0xe9}!&quot;</span>
<span class="ident">OsString</span>::<span class="ident">from_vec</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0xe9</span>, <span class="string">b&#39;!&#39;</span>])]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">itr</span> <span class="op">=</span> <span class="ident">m</span>.<span class="ident">values_of_os</span>(<span class="string">&quot;arg&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">into_iter</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="ident">OsStr</span>::<span class="ident">new</span>(<span class="string">&quot;Hi&quot;</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="ident">OsStr</span>::<span class="ident">from_bytes</span>(<span class="kw-2">&amp;</span>[<span class="number">0xe9</span>, <span class="string">b&#39;!&#39;</span>])));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);</pre></div>
</div><h4 id='method.is_present' class="method"><code id='is_present.v'>pub fn <a href='#method.is_present' class='fnname'>is_present</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;self, name: S) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#315-322' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if an argument was present at runtime, otherwise <code>false</code>.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;d&quot;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-d&quot;</span>
]);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">is_present</span>(<span class="string">&quot;debug&quot;</span>));</pre></div>
</div><h4 id='method.occurrences_of' class="method"><code id='occurrences_of.v'>pub fn <a href='#method.occurrences_of' class='fnname'>occurrences_of</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;self, name: S) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#363-365' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the number of times an argument was used at runtime. If an argument isn't present
it will return <code>0</code>.</p>
<p><strong>NOTE:</strong> This returns the number of times the argument was used, <em>not</em> the number of
values. For example, <code>-o val1 val2 val3 -o val4</code> would return <code>2</code> (2 occurrences, but 4
values).</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;d&quot;</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-d&quot;</span>, <span class="string">&quot;-d&quot;</span>, <span class="string">&quot;-d&quot;</span>
]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">occurrences_of</span>(<span class="string">&quot;debug&quot;</span>), <span class="number">3</span>);</pre></div>
<p>This next example shows that counts actual uses of the argument, not just <code>-</code>'s</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;d&quot;</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;f&quot;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-ddfd&quot;</span>
]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">occurrences_of</span>(<span class="string">&quot;debug&quot;</span>), <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">occurrences_of</span>(<span class="string">&quot;flag&quot;</span>), <span class="number">1</span>);</pre></div>
</div><h4 id='method.index_of' class="method"><code id='index_of.v'>pub fn <a href='#method.index_of' class='fnname'>index_of</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;self, name: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#497-504' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets the starting index of the argument in respect to all other arguments. Indices are
similar to argv indices, but are not exactly 1:1.</p>
<p>For flags (i.e. those arguments which don't have an associated value), indices refer
to occurrence of the switch, such as <code>-f</code>, or <code>--flag</code>. However, for options the indices
refer to the <em>values</em> <code>-o val</code> would therefore not represent two distinct indices, only the
index for <code>val</code> would be recorded. This is by design.</p>
<p>Besides the flag/option descrepancy, the primary difference between an argv index and clap
index, is that clap continues counting once all arguments have properly seperated, whereas
an argv index does not.</p>
<p>The examples should clear this up.</p>
<p><em>NOTE:</em> If an argument is allowed multiple times, this method will only give the <em>first</em>
index.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<p>The argv indices are listed in the comments below. See how they correspond to the clap
indices. Note that if it's not listed in a clap index, this is becuase it's not saved in
in an <code>ArgMatches</code> struct for querying.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;f&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-f&quot;</span>, <span class="string">&quot;-o&quot;</span>, <span class="string">&quot;val&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1 ^2 ^3</span>
<span class="comment">// clap idices: ^1 ^3</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;option&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">3</span>));</pre></div>
<p>Now notice, if we use one of the other styles of options:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;f&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-f&quot;</span>, <span class="string">&quot;-o=val&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1 ^2</span>
<span class="comment">// clap idices: ^1 ^3</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;option&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">3</span>));</pre></div>
<p>Things become much more complicated, or clear if we look at a more complex combination of
flags. Let's also throw in the final option style for good measure.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;f&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag2&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;F&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag3&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;z&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-fzF&quot;</span>, <span class="string">&quot;-oval&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1 ^2</span>
<span class="comment">// clap idices: ^1,2,3 ^5</span>
<span class="comment">//</span>
<span class="comment">// clap sees the above as &#39;myapp -f -z -F -o val&#39;</span>
<span class="comment">// ^0 ^1 ^2 ^3 ^4 ^5</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag2&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">3</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag3&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;option&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">5</span>));</pre></div>
<p>One final combination of flags/options to see how they combine:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;f&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag2&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;F&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag3&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;z&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-fzFoval&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1</span>
<span class="comment">// clap idices: ^1,2,3^5</span>
<span class="comment">//</span>
<span class="comment">// clap sees the above as &#39;myapp -f -z -F -o val&#39;</span>
<span class="comment">// ^0 ^1 ^2 ^3 ^4 ^5</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag2&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">3</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;flag3&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;option&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">5</span>));</pre></div>
<p>The last part to mention is when values are sent in multiple groups with a <a href="./struct.Arg.html#method.value_delimiter">delimiter</a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o=val1,val2,val3&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1</span>
<span class="comment">// clap idices: ^2 ^3 ^4</span>
<span class="comment">//</span>
<span class="comment">// clap sees the above as &#39;myapp -o val1 val2 val3&#39;</span>
<span class="comment">// ^0 ^1 ^2 ^3 ^4</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">index_of</span>(<span class="string">&quot;option&quot;</span>), <span class="prelude-val">Some</span>(<span class="number">2</span>));</pre></div>
</div><h4 id='method.indices_of' class="method"><code id='indices_of.v'>pub fn <a href='#method.indices_of' class='fnname'>indices_of</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(&amp;'a self, name: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Indices&lt;'a&gt;&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#579-588' title='goto source code'>[src]</a></h4><div class='docblock'><p>Gets all indices of the argument in respect to all other arguments. Indices are
similar to argv indices, but are not exactly 1:1.</p>
<p>For flags (i.e. those arguments which don't have an associated value), indices refer
to occurrence of the switch, such as <code>-f</code>, or <code>--flag</code>. However, for options the indices
refer to the <em>values</em> <code>-o val</code> would therefore not represent two distinct indices, only the
index for <code>val</code> would be recorded. This is by design.</p>
<p><em>NOTE:</em> For more information about how clap indices compare to argv indices, see
<a href="./struct.ArgMatches.html#method.index_of"><code>ArgMatches::index_of</code></a></p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>)
.<span class="ident">use_delimiter</span>(<span class="bool-val">true</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o=val1,val2,val3&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1</span>
<span class="comment">// clap idices: ^2 ^3 ^4</span>
<span class="comment">//</span>
<span class="comment">// clap sees the above as &#39;myapp -o val1 val2 val3&#39;</span>
<span class="comment">// ^0 ^1 ^2 ^3 ^4</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">indices_of</span>(<span class="string">&quot;option&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>(), <span class="kw-2">&amp;</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);</pre></div>
<p>Another quick example is when flags and options are used together</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;f&quot;</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o&quot;</span>, <span class="string">&quot;val1&quot;</span>, <span class="string">&quot;-f&quot;</span>, <span class="string">&quot;-o&quot;</span>, <span class="string">&quot;val2&quot;</span>, <span class="string">&quot;-f&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1 ^2 ^3 ^4 ^5 ^6</span>
<span class="comment">// clap idices: ^2 ^3 ^5 ^6</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">indices_of</span>(<span class="string">&quot;option&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>(), <span class="kw-2">&amp;</span>[<span class="number">2</span>, <span class="number">5</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">indices_of</span>(<span class="string">&quot;flag&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>(), <span class="kw-2">&amp;</span>[<span class="number">3</span>, <span class="number">6</span>]);</pre></div>
<p>One final example, which is an odd case; if we <em>don't</em> use value delimiter as we did with
the first example above instead of <code>val1</code>, <code>val2</code> and <code>val3</code> all being distinc values, they
would all be a single value of <code>val1,val2,val3</code>, in which case case they'd only receive a
single index.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;o&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>)
.<span class="ident">multiple</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o=val1,val2,val3&quot;</span>]);
<span class="comment">// ARGV idices: ^0 ^1</span>
<span class="comment">// clap idices: ^2</span>
<span class="comment">//</span>
<span class="comment">// clap sees the above as &#39;myapp -o &quot;val1,val2,val3&quot;&#39;</span>
<span class="comment">// ^0 ^1 ^2</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">m</span>.<span class="ident">indices_of</span>(<span class="string">&quot;option&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>(), <span class="kw-2">&amp;</span>[<span class="number">2</span>]);</pre></div>
</div><h4 id='method.subcommand_matches' class="method"><code id='subcommand_matches.v'>pub fn <a href='#method.subcommand_matches' class='fnname'>subcommand_matches</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: S<br>) -&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;<a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#621-628' title='goto source code'>[src]</a></h4><div class='docblock'><p>Because <a href="./struct.SubCommand.html"><code>Subcommand</code></a>s are essentially &quot;sub-<a href="./struct.App.html"><code>App</code></a>s&quot; they have their own <a href="./struct.ArgMatches.html"><code>ArgMatches</code></a>
as well. This method returns the <a href="./struct.ArgMatches.html"><code>ArgMatches</code></a> for a particular subcommand or <code>None</code> if
the subcommand wasn't present at runtime.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&quot;d&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;test&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg</span>::<span class="ident">with_name</span>(<span class="string">&quot;opt&quot;</span>)
.<span class="ident">long</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">takes_value</span>(<span class="bool-val">true</span>)))
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-d&quot;</span>, <span class="string">&quot;test&quot;</span>, <span class="string">&quot;--option&quot;</span>, <span class="string">&quot;val&quot;</span>
]);
<span class="comment">// Both parent commands, and child subcommands can have arguments present at the same times</span>
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">app_m</span>.<span class="ident">is_present</span>(<span class="string">&quot;debug&quot;</span>));
<span class="comment">// Get the subcommand&#39;s ArgMatches instance</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">sub_m</span>) <span class="op">=</span> <span class="ident">app_m</span>.<span class="ident">subcommand_matches</span>(<span class="string">&quot;test&quot;</span>) {
<span class="comment">// Use the struct like normal</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">sub_m</span>.<span class="ident">value_of</span>(<span class="string">&quot;opt&quot;</span>), <span class="prelude-val">Some</span>(<span class="string">&quot;val&quot;</span>));
}</pre></div>
</div><h4 id='method.subcommand_name' class="method"><code id='subcommand_name.v'>pub fn <a href='#method.subcommand_name' class='fnname'>subcommand_name</a>(&amp;self) -&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;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#688-690' title='goto source code'>[src]</a></h4><div class='docblock'><p>Because <a href="./struct.SubCommand.html"><code>Subcommand</code></a>s are essentially &quot;sub-<a href="./struct.App.html"><code>App</code></a>s&quot; they have their own <a href="./struct.ArgMatches.html"><code>ArgMatches</code></a>
as well.But simply getting the sub-<a href="./struct.ArgMatches.html"><code>ArgMatches</code></a> doesn't help much if we don't also know
which subcommand was actually used. This method returns the name of the subcommand that was
used at runtime, or <code>None</code> if one wasn't.</p>
<p><em>NOTE</em>: Subcommands form a hierarchy, where multiple subcommands can be used at runtime,
but only a single subcommand from any group of sibling commands may used at once.</p>
<p>An ASCII art depiction may help explain this better...Using a fictional version of <code>git</code> as
the demo subject. Imagine the following are all subcommands of <code>git</code> (note, the author is
aware these aren't actually all subcommands in the real <code>git</code> interface, but it makes
explanation easier)</p>
<pre><code class="language-notrust"> Top Level App (git) TOP
|
-----------------------------------------
/ | \ \
clone push add commit LEVEL 1
| / \ / \ |
url origin remote ref name message LEVEL 2
/ /\
path remote local LEVEL 3
</code></pre>
<p>Given the above fictional subcommand hierarchy, valid runtime uses would be (not an all
inclusive list, and not including argument options per command for brevity and clarity):</p>
<pre><code class="language-sh">$ git clone url
$ git push origin path
$ git add ref local
$ git commit message
</code></pre>
<p>Notice only one command per &quot;level&quot; may be used. You could not, for example, do <code>$ git clone url push origin path</code></p>
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;git&quot;</span>)
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;clone&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;push&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;commit&quot;</span>))
.<span class="ident">get_matches</span>();
<span class="kw">match</span> <span class="ident">app_m</span>.<span class="ident">subcommand_name</span>() {
<span class="prelude-val">Some</span>(<span class="string">&quot;clone&quot;</span>) <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// clone was used</span>
<span class="prelude-val">Some</span>(<span class="string">&quot;push&quot;</span>) <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// push was used</span>
<span class="prelude-val">Some</span>(<span class="string">&quot;commit&quot;</span>) <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// commit was used</span>
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// Either no subcommand or one not tested for...</span>
}</pre></div>
</div><h4 id='method.subcommand' class="method"><code id='subcommand.v'>pub fn <a href='#method.subcommand' class='fnname'>subcommand</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;&gt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#739-743' title='goto source code'>[src]</a></h4><div class='docblock'><p>This brings together <a href="./struct.ArgMatches.html#method.subcommand_matches"><code>ArgMatches::subcommand_matches</code></a> and <a href="./struct.ArgMatches.html#method.subcommand_name"><code>ArgMatches::subcommand_name</code></a>
by returning a tuple with both pieces of information.</p>
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;git&quot;</span>)
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;clone&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;push&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;commit&quot;</span>))
.<span class="ident">get_matches</span>();
<span class="kw">match</span> <span class="ident">app_m</span>.<span class="ident">subcommand</span>() {
(<span class="string">&quot;clone&quot;</span>, <span class="prelude-val">Some</span>(<span class="ident">sub_m</span>)) <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// clone was used</span>
(<span class="string">&quot;push&quot;</span>, <span class="prelude-val">Some</span>(<span class="ident">sub_m</span>)) <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// push was used</span>
(<span class="string">&quot;commit&quot;</span>, <span class="prelude-val">Some</span>(<span class="ident">sub_m</span>)) <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// commit was used</span>
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> {}, <span class="comment">// Either no subcommand or one not tested for...</span>
}</pre></div>
<p>Another useful scenario is when you want to support third party, or external, subcommands.
In these cases you can't know the subcommand name ahead of time, so use a variable instead
with pattern matching!</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="comment">// Assume there is an external subcommand named &quot;subcmd&quot;</span>
<span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">setting</span>(<span class="ident">AppSettings</span>::<span class="ident">AllowExternalSubcommands</span>)
.<span class="ident">get_matches_from</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;subcmd&quot;</span>, <span class="string">&quot;--option&quot;</span>, <span class="string">&quot;value&quot;</span>, <span class="string">&quot;-fff&quot;</span>, <span class="string">&quot;--flag&quot;</span>
]);
<span class="comment">// All trailing arguments will be stored under the subcommand&#39;s sub-matches using an empty</span>
<span class="comment">// string argument name</span>
<span class="kw">match</span> <span class="ident">app_m</span>.<span class="ident">subcommand</span>() {
(<span class="ident">external</span>, <span class="prelude-val">Some</span>(<span class="ident">sub_m</span>)) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">ext_args</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">sub_m</span>.<span class="ident">values_of</span>(<span class="string">&quot;&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">external</span>, <span class="string">&quot;subcmd&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">ext_args</span>, [<span class="string">&quot;--option&quot;</span>, <span class="string">&quot;value&quot;</span>, <span class="string">&quot;-fff&quot;</span>, <span class="string">&quot;--flag&quot;</span>]);
},
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> {},
}</pre></div>
</div><h4 id='method.usage' class="method"><code id='usage.v'>pub fn <a href='#method.usage' class='fnname'>usage</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#759' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a string slice of the usage statement for the <a href="./struct.App.html"><code>App</code></a> or <a href="./struct.SubCommand.html"><code>SubCommand</code></a></p>
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">subcommand</span>(<span class="ident">SubCommand</span>::<span class="ident">with_name</span>(<span class="string">&quot;test&quot;</span>))
.<span class="ident">get_matches</span>();
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">app_m</span>.<span class="ident">usage</span>());</pre></div>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Default' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-Default' class='anchor'></a><a class='srclink' href='../src/clap/args/arg_matches.rs.html#67-75' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.default' class="method hidden"><code id='default.v'>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; Self</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#68-74' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns the &quot;default value&quot; for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
</div></div><h3 id='impl-Clone' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-Clone' class='anchor'></a><a class='srclink' href='../src/clap/args/arg_matches.rs.html#60' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.clone' class="method hidden"><code id='clone.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#60' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class="method hidden"><code id='clone_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#131-133' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../src/clap/args/arg_matches.rs.html#60' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class='srclink' href='../src/clap/args/arg_matches.rs.html#60' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
2019-09-16 15:53:39 -07:00
</div></div></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'><h3 id='impl-Sync' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Send' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Unpin' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-Unpin' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-RefUnwindSafe' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-RefUnwindSafe' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-UnwindSafe' class='impl'><code class='in-band'>impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../clap/struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a>&lt;'a&gt;</code><a href='#impl-UnwindSafe' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Into%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#543-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#545-547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-From%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href='#impl-From%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#552-554' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#553' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
2019-09-06 15:57:44 -07:00
</div></div><h3 id='impl-ToOwned' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code><a href='#impl-ToOwned' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#81-92' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Owned' class="type"><code id='Owned.t'>type <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned' class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
</div><h4 id='method.to_owned' class="method hidden"><code id='to_owned.v'>fn <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned' class='fnname'>to_owned</a>(&amp;self) -&gt; T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div><h4 id='method.clone_into' class="method hidden"><code id='clone_into.v'>fn <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into' class='fnname'>clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T)</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></div><h3 id='impl-TryFrom%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryFrom%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#571-577' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#574-576' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryInto%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#559-566' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#563-565' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-BorrowMut%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><code id='borrow_mut.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id='impl-Borrow%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><code id='borrow.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div></div></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><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "clap";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>