<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="API documentation for the Rust `ArgMatches` struct in crate `clap`."><metaname="keywords"content="rust, rustlang, rust-lang, ArgMatches"><title>clap::ArgMatches - Rust</title><linkrel="stylesheet"type="text/css"href="../normalize.css"><linkrel="stylesheet"type="text/css"href="../rustdoc.css"id="mainThemeStyle"><linkrel="stylesheet"type="text/css"href="../dark.css"><linkrel="stylesheet"type="text/css"href="../light.css"id="themeStyle"><scriptsrc="../storage.js"></script><noscript><linkrel="stylesheet"href="../noscript.css"></noscript><linkrel="shortcut icon"href="../favicon.ico"><styletype="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><bodyclass="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="sidebar"><divclass="sidebar-menu">☰</div><ahref='../clap/index.html'><divclass='logo-container'><imgsrc='../rust-logo.png'alt='logo'></div></a><pclass='location'>Struct ArgMatches</p><divclass="sidebar-elems"><divclass="block items"><aclass="sidebar-title"href="#methods">Methods</a><divclass="sidebar-links"><ahref="#method.index_of">index_of</a><ahref="#method.indices_of">indices_of</a><ahref="#method.is_present">is_present</a><ahref="#method.occurrences_of">occurrences_of</a><ahref="#method.subcommand">subcommand</a><ahref="#method.subcommand_matches">subcommand_matches</a><ahref="#method.subcommand_name">subcommand_name</a><ahref="#method.usage">usage</a><ahref="#method.value_of">value_of</a><ahref="#method.value_of_lossy">value_of_lossy</a><ahref="#method.value_of_os">value_of_os</a><ahref="#method.values_of">values_of</a><ahref="#method.values_of_lossy">values_of_lossy</a><ahref="#method.values_of_os">values_of_os</a></div><aclass="sidebar-title"href="#implementations">Trait Implementations</a><divclass="sidebar-links"><ahref="#impl-Clone">Clone</a><ahref="#impl-Debug">Debug</a><ahref="#impl-Default">Default</a></div><aclass="sidebar-title"href="#synthetic-implementations">Auto Trait Implementations</a><divclass="sidebar-links"><ahref="#impl-RefUnwindSafe">RefUnwindSafe</a><ahref="#impl-Send">Send</a><ahref="#impl-Sync">Sync</a><ahref="#impl-Unpin">Unpin</a><ahref="#impl-UnwindSafe">UnwindSafe</a></div><aclass="sidebar-title"href="#blanket-implementations">Blanket Implementations</a><divclass="sidebar-links"><ahref="#impl-Any">Any</a><ahref="#impl-Borrow%3CT%3E">Borrow<T></a><ahref="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><ahref="#impl-From%3CT%3E">From<T></a><ahref="#impl-Into%3CU%3E">Into<U></a><ahref="#impl-ToOwned">ToOwned</a><ahref="#impl-TryFrom%3CU%3E">TryFrom<U></a><ahref="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><pclass='location'><ahref='index.html'>clap</a></p><script>window.sidebarCurrent={name:'ArgMatches',ty:'struct',relpath:''};</script><scriptdefersrc="sidebar-items.js"></script></div></nav><divclass="theme-picker"><buttonid="theme-picker"aria-label="Pick another theme!"><imgsrc="../brush.svg"width="18"alt="Pick another theme!"></button><divid="theme-choices"></div></div><scriptsrc="../theme.js"></script><navclass="sub"><formclass="search-form js-only"><divclass="search-container"><div><selectid="crate-search"><optionvalue="All crates">All crates</option></select><inputclass="search-input"name="search"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"></div><aid="settings-menu"href="../settings.html"><imgsrc="../wheel.svg"width="18"alt="Change settings"></a></div></form></nav><sectionid="main"class="content"><h1class='fqn'><spanclass='out-of-band'><spanid='render-detail'><aid="toggle-all-docs"href="javascript:void(0)"title="collapse
the user. New instances of this struct are obtained by using the <ahref="./struct.App.html#method.get_matches"><code>App::get_matches</code></a> family of
<spanclass="macro">println</span><spanclass="macro">!</span>(<spanclass="string">"Value for -c: {}"</span>, <spanclass="ident">c</span>);
}
<spanclass="comment">// The ArgMatches::value_of method returns an Option because the user may not have supplied</span>
<spanclass="comment">// that argument at runtime. But if we specified that the argument was "required" as we did</span>
<spanclass="comment">// with the "out" argument, we can safely unwrap because `clap` verifies that was actually</span>
<spanclass="comment">// used at runtime.</span>
<spanclass="macro">println</span><spanclass="macro">!</span>(<spanclass="string">"Value for --output: {}"</span>, <spanclass="ident">matches</span>.<spanclass="ident">value_of</span>(<spanclass="string">"out"</span>).<spanclass="ident">unwrap</span>());
<spanclass="comment">// You can check the presence of an argument</span>
<spanclass="macro">println</span><spanclass="macro">!</span>(<spanclass="string">"Debug mode is REALLY on, don't be crazy"</span>);
} <spanclass="kw">else</span> {
<spanclass="macro">println</span><spanclass="macro">!</span>(<spanclass="string">"Debug mode kind of on"</span>);
}
}</pre></div>
</div><h2id='methods'class='small-section-header'>Methods<ahref='#methods'class='anchor'></a></h2><h3id='impl'class='impl'><codeclass='in-band'>impl<'a><aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a></code><ahref='#impl'class='anchor'></a><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#77-760'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.value_of'class="method"><codeid='value_of.v'>pub fn <ahref='#method.value_of'class='fnname'>value_of</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><&<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#112-119'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Gets the value of a specific <ahref="./struct.Arg.html#method.takes_value">option</a> or <ahref="./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 <ahref="./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>
<p>This method will <ahref="https://doc.rust-lang.org/std/macro.panic!.html"><code>panic!</code></a> if the value contains invalid UTF-8 code points.</p>
</div><h4id='method.value_of_lossy'class="method"><codeid='value_of_lossy.v'>pub fn <ahref='#method.value_of_lossy'class='fnname'>value_of_lossy</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&'a self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="enum"href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html"title="enum alloc::borrow::Cow">Cow</a><'a, <aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#144-151'title='goto source code'>[src]</a></h4><divclass='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 <ahref="./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>
</div><h4id='method.value_of_os'class="method"><codeid='value_of_os.v'>pub fn <ahref='#method.value_of_os'class='fnname'>value_of_os</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><&<aclass="struct"href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html"title="struct std::ffi::os_str::OsStr">OsStr</a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#180-184'title='goto source code'>[src]</a></h4><divclass='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 <ahref="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 <ahref="./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>
</div><h4id='method.values_of'class="method"><codeid='values_of.v'>pub fn <ahref='#method.values_of'class='fnname'>values_of</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&'a self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../clap/struct.Values.html"title="struct clap::Values">Values</a><'a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#211-220'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Gets a <ahref="./struct.Values.html"><code>Values</code></a> struct which implements <ahref="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
</div><h4id='method.values_of_lossy'class="method"><codeid='values_of_lossy.v'>pub fn <ahref='#method.values_of_lossy'class='fnname'>values_of_lossy</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&'a self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html"title="struct alloc::vec::Vec">Vec</a><<aclass="struct"href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html"title="struct alloc::string::String">String</a>>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#246-256'title='goto source code'>[src]</a></h4><divclass='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>
</div><h4id='method.values_of_os'class="method"><codeid='values_of_os.v'>pub fn <ahref='#method.values_of_os'class='fnname'>values_of_os</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&'a self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../clap/struct.OsValues.html"title="struct clap::OsValues">OsValues</a><'a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#289-298'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Gets a <ahref="./struct.OsValues.html"><code>OsValues</code></a> struct which is implements <ahref="https://doc.rust-lang.org/std/iter/trait.Iterator.html"><code>Iterator</code></a> for <ahref="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 <ahref="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>
</div><h4id='method.is_present'class="method"><codeid='is_present.v'>pub fn <ahref='#method.is_present'class='fnname'>is_present</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&self, name: S) -><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#315-322'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Returns <code>true</code> if an argument was present at runtime, otherwise <code>false</code>.</p>
</div><h4id='method.occurrences_of'class="method"><codeid='occurrences_of.v'>pub fn <ahref='#method.occurrences_of'class='fnname'>occurrences_of</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&self, name: S) -><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#363-365'title='goto source code'>[src]</a></h4><divclass='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
</div><h4id='method.index_of'class="method"><codeid='index_of.v'>pub fn <ahref='#method.index_of'class='fnname'>index_of</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#497-504'title='goto source code'>[src]</a></h4><divclass='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>
</div><h4id='method.indices_of'class="method"><codeid='indices_of.v'>pub fn <ahref='#method.indices_of'class='fnname'>indices_of</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(&'a self, name: S) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><Indices<'a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#579-588'title='goto source code'>[src]</a></h4><divclass='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
</div><h4id='method.subcommand_matches'class="method"><codeid='subcommand_matches.v'>pub fn <ahref='#method.subcommand_matches'class='fnname'>subcommand_matches</a><S: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(<br> &self, <br> name: S<br>) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><&<aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#621-628'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Because <ahref="./struct.SubCommand.html"><code>Subcommand</code></a>s are essentially "sub-<ahref="./struct.App.html"><code>App</code></a>s" they have their own <ahref="./struct.ArgMatches.html"><code>ArgMatches</code></a>
as well. This method returns the <ahref="./struct.ArgMatches.html"><code>ArgMatches</code></a> for a particular subcommand or <code>None</code> if
</div><h4id='method.subcommand_name'class="method"><codeid='subcommand_name.v'>pub fn <ahref='#method.subcommand_name'class='fnname'>subcommand_name</a>(&self) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><&<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#688-690'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Because <ahref="./struct.SubCommand.html"><code>Subcommand</code></a>s are essentially "sub-<ahref="./struct.App.html"><code>App</code></a>s" they have their own <ahref="./struct.ArgMatches.html"><code>ArgMatches</code></a>
as well.But simply getting the sub-<ahref="./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><codeclass="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><codeclass="language-sh">$ git clone url
$ git push origin path
$ git add ref local
$ git commit message
</code></pre>
<p>Notice only one command per "level" may be used. You could not, for example, do <code>$ git clone url push origin path</code></p>
<spanclass="prelude-val">Some</span>(<spanclass="string">"clone"</span>) <spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// clone was used</span>
<spanclass="prelude-val">Some</span>(<spanclass="string">"push"</span>) <spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// push was used</span>
<spanclass="prelude-val">Some</span>(<spanclass="string">"commit"</span>) <spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// commit was used</span>
<spanclass="kw">_</span><spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// Either no subcommand or one not tested for...</span>
}</pre></div>
</div><h4id='method.subcommand'class="method"><codeid='subcommand.v'>pub fn <ahref='#method.subcommand'class='fnname'>subcommand</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>&<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><&<aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a>><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#739-743'title='goto source code'>[src]</a></h4><divclass='docblock'><p>This brings together <ahref="./struct.ArgMatches.html#method.subcommand_matches"><code>ArgMatches::subcommand_matches</code></a> and <ahref="./struct.ArgMatches.html#method.subcommand_name"><code>ArgMatches::subcommand_name</code></a>
by returning a tuple with both pieces of information.</p>
(<spanclass="string">"clone"</span>, <spanclass="prelude-val">Some</span>(<spanclass="ident">sub_m</span>)) <spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// clone was used</span>
(<spanclass="string">"push"</span>, <spanclass="prelude-val">Some</span>(<spanclass="ident">sub_m</span>)) <spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// push was used</span>
(<spanclass="string">"commit"</span>, <spanclass="prelude-val">Some</span>(<spanclass="ident">sub_m</span>)) <spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="comment">// commit was used</span>
<spanclass="kw">_</span><spanclass="op">=</span><spanclass="op">></span> {}, <spanclass="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
</div><h4id='method.usage'class="method"><codeid='usage.v'>pub fn <ahref='#method.usage'class='fnname'>usage</a>(&self) ->&<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#759'title='goto source code'>[src]</a></h4><divclass='docblock'><p>Returns a string slice of the usage statement for the <ahref="./struct.App.html"><code>App</code></a> or <ahref="./struct.SubCommand.html"><code>SubCommand</code></a></p>
</div></div><h2id='implementations'class='small-section-header'>Trait Implementations<ahref='#implementations'class='anchor'></a></h2><divid='implementations-list'><h3id='impl-Default'class='impl'><codeclass='in-band'>impl<'a><aclass="trait"href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html"title="trait core::default::Default">Default</a> for <aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a></code><ahref='#impl-Default'class='anchor'></a><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#67-75'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.default'class="method hidden"><codeid='default.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default'class='fnname'>default</a>() -> Self</code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#68-74'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Returns the "default value" for a type. <ahref="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
</div></div><h3id='impl-Clone'class='impl'><codeclass='in-band'>impl<'a><aclass="trait"href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a> for <aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a></code><ahref='#impl-Clone'class='anchor'></a><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#60'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.clone'class="method hidden"><codeid='clone.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone'class='fnname'>clone</a>(&self) -><aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#60'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Returns a copy of the value. <ahref="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4id='method.clone_from'class="method hidden"><codeid='clone_from.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from'class='fnname'>clone_from</a>(&mut self, source: <aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><spanclass='since'title='Stable since Rust version 1.0.0'>1.0.0</span><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#131-133'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <ahref="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3id='impl-Debug'class='impl'><codeclass='in-band'>impl<'a><aclass="trait"href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html"title="trait core::fmt::Debug">Debug</a> for <aclass="struct"href="../clap/struct.ArgMatches.html"title="struct clap::ArgMatches">ArgMatches</a><'a></code><ahref='#impl-Debug'class='anchor'></a><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#60'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.fmt'class="method hidden"><codeid='fmt.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt'class='fnname'>fmt</a>(&self, f: &mut <aclass="struct"href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html"title="struct core::fmt::Formatter">Formatter</a>) -><aclass="type"href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html"title="type core::fmt::Result">Result</a></code><aclass='srclink'href='../src/clap/args/arg_matches.rs.html#60'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Formats the value using the given formatter. <ahref="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3id='impl-ToOwned'class='impl'><codeclass='in-band'>impl<T><aclass="trait"href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html"title="trait alloc::borrow::ToOwned">ToOwned</a> for T <spanclass="where fmt-newline">where<br> T: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a>, </span></code><ahref='#impl-ToOwned'class='anchor'></a><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#81-92'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='associatedtype.Owned'class="type"><codeid='Owned.t'>type <ahref='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned'class="type">Owned</a> = T</code></h4><divclass='docblock'><p>The resulting type after obtaining ownership.</p>
</div><h4id='method.to_owned'class="method hidden"><codeid='to_owned.v'>fn <ahref='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned'class='fnname'>to_owned</a>(&self) -> T</code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <ahref="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div><h4id='method.clone_into'class="method hidden"><codeid='clone_into.v'>fn <ahref='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into'class='fnname'>clone_into</a>(&self, target: <aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91'title='goto source code'>[src]</a></h4><divclass='stability hidden'><divclass='stab unstable'><details><summary><spanclass='emoji'>🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
</details></div></div><divclass='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <ahref="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></div><h3id='impl-TryFrom%3CU%3E'class='impl'><codeclass='in-band'>impl<T, U><aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U> for T <spanclass="where fmt-newline">where<br> U: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><T>, </span></code><ahref='#impl-TryFrom%3CU%3E'class='anchor'></a><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#571-577'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='associatedtype.Error'class="type"><codeid='Error.t'>type <ahref='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error'class="type">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html"title="enum core::convert::Infallible">Infallible</a></code></h4><divclass='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4id='method.try_from'class="method hidden"><codeid='try_from.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from'class='fnname'>try_from</a>(value: U) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"title="enum core::result::Result">Result</a><T, <T as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="type"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#574-576'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3id='impl-TryInto%3CU%3E'class='impl'><codeclass='in-band'>impl<T, U><aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><U> for T <spanclass="where fmt-newline">where<br> U: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><ahref='#impl-TryInto%3CU%3E'class='anchor'></a><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#559-566'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='associatedtype.Error-1'class="type"><codeid='Error.t-1'>type <ahref='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error'class="type">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="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><divclass='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4id='method.try_into'class="method hidden"><codeid='try_into.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into'class='fnname'>try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"title="enum core::result::Result">Result</a><U, <U as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="type"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#563-565'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3id='impl-BorrowMut%3CT%3E'class='impl'><codeclass='in-band'>impl<T><aclass="trait"href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html"title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <spanclass="where fmt-newline">where<br> T: ?<aclass="trait"href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>, </span></code><ahref='#impl-BorrowMut%3CT%3E'class='anchor'></a><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.borrow_mut'class="method hidden"><codeid='borrow_mut.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut'class='fnname'>borrow_mut</a>(&mut self) -><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Mutably borrows from an owned value. <ahref="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3id='impl-Borrow%3CT%3E'class='impl'><codeclass='in-band'>impl<T><aclass="trait"href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html"title="trait core::borrow::Borrow">Borrow</a><T> for T <spanclass="where fmt-newline">where<br> T: ?<aclass="trait"href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>, </span></code><ahref='#impl-Borrow%3CT%3E'class='anchor'></a><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213-215'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.borrow'class="method hidden"><codeid='borrow.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow'class='fnname'>borrow</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Immutably borrows from an owned value. <ahref="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3id='impl-Any'class='impl'><codeclass='in-band'>impl<T><aclass="trait"href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html"title="trait core::any::Any">Any</a> for T <spanclass="where fmt-newline">where<br> T: 'static + ?<aclass="trait"href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>, </span></code><ahref='#impl-Any'class='anchor'></a><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#100-102'title='goto source code'>[src]</a></h3><divclass='impl-items'><h4id='method.type_id'class="method hidden"><codeid='type_id.v'>fn <ahref='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id'class='fnname'>type_id</a>(&self) -><aclass="struct"href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html"title="struct core::any::TypeId">TypeId</a></code><aclass='srclink'href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#101'title='goto source code'>[src]</a></h4><divclass='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <ahref="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div></div></section><sectionid="search"class="content hidden"></section><sectionclass="footer"></section><asideid="help"class="hidden"><div><h1class="hidden">Help</h1><divclass="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>⏎</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><divclass="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><scriptsrc="../aliases.js"></script><scriptsrc="../main.js"></script><scriptdefersrc="../search-index.js"></script></body></html>