ssw/doc/clap/struct.ArgMatches.html
2023-01-09 19:23:20 +01:00

557 lines
121 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Container for parse results."><meta name="keywords" content="rust, rustlang, rust-lang, ArgMatches"><title>ArgMatches in clap - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><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="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../clap/index.html"><div class="logo-container"><img src="https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../clap/index.html"><div class="logo-container">
<img src="https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png" alt="logo"></div></a><h2 class="location"><a href="#">ArgMatches</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#implementations">Methods</a></h3><ul><li><a href="#method.args_present">args_present</a></li><li><a href="#method.contains_id">contains_id</a></li><li><a href="#method.get_count">get_count</a></li><li><a href="#method.get_flag">get_flag</a></li><li><a href="#method.get_many">get_many</a></li><li><a href="#method.get_one">get_one</a></li><li><a href="#method.get_raw">get_raw</a></li><li><a href="#method.ids">ids</a></li><li><a href="#method.index_of">index_of</a></li><li><a href="#method.indices_of">indices_of</a></li><li><a href="#method.remove_many">remove_many</a></li><li><a href="#method.remove_one">remove_one</a></li><li><a href="#method.remove_subcommand">remove_subcommand</a></li><li><a href="#method.subcommand">subcommand</a></li><li><a href="#method.subcommand_matches">subcommand_matches</a></li><li><a href="#method.subcommand_name">subcommand_name</a></li><li><a href="#method.try_contains_id">try_contains_id</a></li><li><a href="#method.try_get_many">try_get_many</a></li><li><a href="#method.try_get_one">try_get_one</a></li><li><a href="#method.try_get_raw">try_get_raw</a></li><li><a href="#method.try_remove_many">try_remove_many</a></li><li><a href="#method.try_remove_one">try_remove_one</a></li><li><a href="#method.value_source">value_source</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#trait-implementations">Trait Implementations</a></h3><ul><li><a href="#impl-Clone-for-ArgMatches">Clone</a></li><li><a href="#impl-Debug-for-ArgMatches">Debug</a></li><li><a href="#impl-Default-for-ArgMatches">Default</a></li><li><a href="#impl-Eq-for-ArgMatches">Eq</a></li><li><a href="#impl-PartialEq%3CArgMatches%3E-for-ArgMatches">PartialEq&lt;ArgMatches&gt;</a></li><li><a href="#impl-StructuralEq-for-ArgMatches">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-ArgMatches">StructuralPartialEq</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul><li><a href="#impl-RefUnwindSafe-for-ArgMatches">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-ArgMatches">Send</a></li><li><a href="#impl-Sync-for-ArgMatches">Sync</a></li><li><a href="#impl-Unpin-for-ArgMatches">Unpin</a></li><li><a href="#impl-UnwindSafe-for-ArgMatches">!UnwindSafe</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#blanket-implementations">Blanket Implementations</a></h3><ul><li><a href="#impl-Any-for-ArgMatches">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-ArgMatches">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-ArgMatches">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-ArgMatches">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-ArgMatches">Into&lt;U&gt;</a></li><li><a href="#impl-ToOwned-for-ArgMatches">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-ArgMatches">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-ArgMatches">TryInto&lt;U&gt;</a></li></ul></div></section><h2 class="location"><a href="index.html">In clap</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../clap/index.html">
<img src="https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">clap</a>::<wbr><a class="struct" href="#">ArgMatches</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#66-73">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust struct"><code>pub struct ArgMatches { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Container for parse results.</p>
<p>Used to get information about the arguments that were supplied to the program at runtime by
the user. New instances of this struct are obtained by using the <a href="builder/struct.Command.html#method.get_matches"><code>Command::get_matches</code></a> family of
methods.</p>
<h2 id="examples"><a href="#examples">Examples</a></h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">matches</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;MyApp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</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">action</span>(<span class="ident">ArgAction::Set</span>)
.<span class="ident">default_value</span>(<span class="string">&quot;-&quot;</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;cfg&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;c&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</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::get_one]</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">get_one</span>::<span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>(<span class="string">&quot;cfg&quot;</span>) {
<span class="macro">println!</span>(<span class="string">&quot;Value for -c: {}&quot;</span>, <span class="ident">c</span>);
}
<span class="comment">// The ArgMatches::get_one 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="string">&quot;Value for --output: {}&quot;</span>, <span class="ident">matches</span>.<span class="ident">get_one</span>::<span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>(<span class="string">&quot;out&quot;</span>).<span class="ident">unwrap</span>());
<span class="comment">// You can check the presence of an argument&#39;s values</span>
<span class="kw">if</span> <span class="ident">matches</span>.<span class="ident">contains_id</span>(<span class="string">&quot;out&quot;</span>) {
<span class="comment">// However, if you want to know where the value came from</span>
<span class="kw">if</span> <span class="ident">matches</span>.<span class="ident">value_source</span>(<span class="string">&quot;out&quot;</span>).<span class="ident">expect</span>(<span class="string">&quot;checked contains_id&quot;</span>) <span class="op">==</span> <span class="ident">ValueSource::CommandLine</span> {
<span class="macro">println!</span>(<span class="string">&quot;`out` set by user&quot;</span>);
} <span class="kw">else</span> {
<span class="macro">println!</span>(<span class="string">&quot;`out` is defaulted&quot;</span>);
}
}</code></pre></div>
</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#76-864">source</a></span><a href="#impl-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="docblock"><h4 id="arguments"><a href="#arguments">Arguments</a></h4></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_one" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#112-114">source</a></span><h4 class="code-header">pub fn <a href="#method.get_one" class="fnname">get_one</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T&gt;</h4></section></summary><div class="docblock"><p>Gets the value of a specific option or positional argument.</p>
<p>i.e. an argument that <a href="builder/struct.Arg.html#method.num_args" title="crate::Arg::num_args">takes an additional value</a> at runtime.</p>
<p>Returns an error if the wrong type was used.</p>
<p>Returns <code>None</code> if the option wasnt present.</p>
<p><em>NOTE:</em> This will always return <code>Some(value)</code> if <a href="builder/struct.Arg.html#method.default_value"><code>default_value</code></a> has been set.
<a href="parser/struct.ArgMatches.html#method.value_source" title="ArgMatches::value_source"><code>ArgMatches::value_source</code></a> can be used to check if a value is present at runtime.</p>
<h5 id="panic"><a href="#panic">Panic</a></h5>
<p>If the argument definition and access mismatch. To handle this case programmatically, see
<a href="parser/struct.ArgMatches.html#method.try_get_one" title="ArgMatches::try_get_one"><code>ArgMatches::try_get_one</code></a>.</p>
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;port&quot;</span>)
.<span class="ident">value_parser</span>(<span class="macro">value_parser!</span>(<span class="ident">usize</span>))
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>)
.<span class="ident">required</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;2020&quot;</span>]);
<span class="kw">let</span> <span class="ident">port</span>: <span class="ident">usize</span> <span class="op">=</span> <span class="kw-2">*</span><span class="ident">m</span>
.<span class="ident">get_one</span>(<span class="string">&quot;port&quot;</span>)
.<span class="ident">expect</span>(<span class="string">&quot;`port`is required&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="ident">port</span>, <span class="number">2020</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_count" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#141-145">source</a></span><h4 class="code-header">pub fn <a href="#method.get_count" class="fnname">get_count</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.u8.html">u8</a></h4></section></summary><div class="docblock"><p>Gets the value of a specific <a href="builder/enum.ArgAction.html#variant.Count" title="crate::ArgAction::Count"><code>ArgAction::Count</code></a> flag</p>
<h5 id="panic-1"><a href="#panic-1">Panic</a></h5>
<p>If the arguments action is not <a href="builder/enum.ArgAction.html#variant.Count" title="crate::ArgAction::Count"><code>ArgAction::Count</code></a></p>
<h5 id="examples-2"><a href="#examples-2">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;mycmd&quot;</span>)
.<span class="ident">arg</span>(
<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">long</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">action</span>(<span class="ident">clap::ArgAction::Count</span>)
);
<span class="kw">let</span> <span class="ident">matches</span> <span class="op">=</span> <span class="ident">cmd</span>.<span class="ident">clone</span>().<span class="ident">try_get_matches_from</span>([<span class="string">&quot;mycmd&quot;</span>, <span class="string">&quot;--flag&quot;</span>, <span class="string">&quot;--flag&quot;</span>]).<span class="ident">unwrap</span>();
<span class="macro">assert_eq!</span>(
<span class="ident">matches</span>.<span class="ident">get_count</span>(<span class="string">&quot;flag&quot;</span>),
<span class="number">2</span>
);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_flag" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#173-177">source</a></span><h4 class="code-header">pub fn <a href="#method.get_flag" class="fnname">get_flag</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Gets the value of a specific <a href="builder/enum.ArgAction.html#variant.SetTrue" title="crate::ArgAction::SetTrue"><code>ArgAction::SetTrue</code></a> or <a href="builder/enum.ArgAction.html#variant.SetFalse" title="crate::ArgAction::SetFalse"><code>ArgAction::SetFalse</code></a> flag</p>
<h5 id="panic-2"><a href="#panic-2">Panic</a></h5>
<p>If the arguments action is not <a href="builder/enum.ArgAction.html#variant.SetTrue" title="crate::ArgAction::SetTrue"><code>ArgAction::SetTrue</code></a> or <a href="builder/enum.ArgAction.html#variant.SetFalse" title="crate::ArgAction::SetFalse"><code>ArgAction::SetFalse</code></a></p>
<h5 id="examples-3"><a href="#examples-3">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;mycmd&quot;</span>)
.<span class="ident">arg</span>(
<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">long</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">action</span>(<span class="ident">clap::ArgAction::SetTrue</span>)
);
<span class="kw">let</span> <span class="ident">matches</span> <span class="op">=</span> <span class="ident">cmd</span>.<span class="ident">clone</span>().<span class="ident">try_get_matches_from</span>([<span class="string">&quot;mycmd&quot;</span>, <span class="string">&quot;--flag&quot;</span>]).<span class="ident">unwrap</span>();
<span class="macro">assert!</span>(<span class="ident">matches</span>.<span class="ident">contains_id</span>(<span class="string">&quot;flag&quot;</span>));
<span class="macro">assert_eq!</span>(
<span class="ident">matches</span>.<span class="ident">get_flag</span>(<span class="string">&quot;flag&quot;</span>),
<span class="bool-val">true</span>
);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_many" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#212-217">source</a></span><h4 class="code-header">pub fn <a href="#method.get_many" class="fnname">get_many</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.ValuesRef.html" title="struct clap::parser::ValuesRef">ValuesRef</a>&lt;'_, T&gt;&gt;</h4></section></summary><div class="docblock"><p>Iterate over values of a specific option or positional argument.</p>
<p>i.e. an argument that takes multiple values at runtime.</p>
<p>Returns an error if the wrong type was used.</p>
<p>Returns <code>None</code> if the option wasnt present.</p>
<h5 id="panic-3"><a href="#panic-3">Panic</a></h5>
<p>If the argument definition and access mismatch. To handle this case programmatically, see
<a href="parser/struct.ArgMatches.html#method.try_get_many" title="ArgMatches::try_get_many"><code>ArgMatches::try_get_many</code></a>.</p>
<h5 id="examples-4"><a href="#examples-4">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;ports&quot;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Append</span>)
.<span class="ident">value_parser</span>(<span class="macro">value_parser!</span>(<span class="ident">usize</span>))
.<span class="ident">short</span>(<span class="string">&#39;p&#39;</span>)
.<span class="ident">required</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-p&quot;</span>, <span class="string">&quot;22&quot;</span>, <span class="string">&quot;-p&quot;</span>, <span class="string">&quot;80&quot;</span>, <span class="string">&quot;-p&quot;</span>, <span class="string">&quot;2020&quot;</span>
]);
<span class="kw">let</span> <span class="ident">vals</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">usize</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">m</span>.<span class="ident">get_many</span>(<span class="string">&quot;ports&quot;</span>)
.<span class="ident">expect</span>(<span class="string">&quot;`port`is required&quot;</span>)
.<span class="ident">copied</span>()
.<span class="ident">collect</span>();
<span class="macro">assert_eq!</span>(<span class="ident">vals</span>, [<span class="number">22</span>, <span class="number">80</span>, <span class="number">2020</span>]);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_raw" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#299-301">source</a></span><h4 class="code-header">pub fn <a href="#method.get_raw" class="fnname">get_raw</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.RawValues.html" title="struct clap::parser::RawValues">RawValues</a>&lt;'_&gt;&gt;</h4></section></summary><div class="docblock"><p>Iterate over the original argument values.</p>
<p>An <code>OsStr</code> on Unix-like systems is any series of bytes, regardless of whether or not they
contain valid UTF-8. Since <a href="https://doc.rust-lang.org/1.64.0/alloc/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.</p>
<p>Returns <code>None</code> if the option wasnt present.</p>
<h5 id="panic-4"><a href="#panic-4">Panic</a></h5>
<p>If the argument definition and access mismatch. To handle this case programmatically, see
<a href="parser/struct.ArgMatches.html#method.try_get_raw" title="ArgMatches::try_get_raw"><code>ArgMatches::try_get_raw</code></a>.</p>
<h5 id="examples-5"><a href="#examples-5">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">std::path::PathBuf</span>;
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;utf8&quot;</span>)
.<span class="ident">arg</span>(<span class="macro">arg!</span>(<span class="op">&lt;</span><span class="ident">arg</span><span class="op">&gt;</span> ... <span class="string">&quot;some arg&quot;</span>).<span class="ident">value_parser</span>(<span class="macro">value_parser!</span>(<span class="ident">PathBuf</span>)))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[<span class="ident">OsString::from</span>(<span class="string">&quot;myprog&quot;</span>),
<span class="comment">// &quot;Hi&quot;</span>
<span class="ident">OsString::from_vec</span>(<span class="macro">vec!</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::from_vec</span>(<span class="macro">vec!</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">get_raw</span>(<span class="string">&quot;arg&quot;</span>)
.<span class="ident">expect</span>(<span class="string">&quot;`port`is required&quot;</span>)
.<span class="ident">into_iter</span>();
<span class="macro">assert_eq!</span>(<span class="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="ident">OsStr::new</span>(<span class="string">&quot;Hi&quot;</span>)));
<span class="macro">assert_eq!</span>(<span class="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="ident">OsStr::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="ident">itr</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.remove_one" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#391-393">source</a></span><h4 class="code-header">pub fn <a href="#method.remove_one" class="fnname">remove_one</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;</h4></section></summary><div class="docblock"><p>Returns the value of a specific option or positional argument.</p>
<p>i.e. an argument that <a href="builder/struct.Arg.html#method.num_args" title="crate::Arg::num_args">takes an additional value</a> at runtime.</p>
<p>Returns an error if the wrong type was used. No item will have been removed.</p>
<p>Returns <code>None</code> if the option wasnt present.</p>
<p><em>NOTE:</em> This will always return <code>Some(value)</code> if <a href="builder/struct.Arg.html#method.default_value"><code>default_value</code></a> has been set.
<a href="parser/struct.ArgMatches.html#method.value_source" title="ArgMatches::value_source"><code>ArgMatches::value_source</code></a> can be used to check if a value is present at runtime.</p>
<h5 id="panic-5"><a href="#panic-5">Panic</a></h5>
<p>If the argument definition and access mismatch. To handle this case programmatically, see
<a href="parser/struct.ArgMatches.html#method.try_remove_one" title="ArgMatches::try_remove_one"><code>ArgMatches::try_remove_one</code></a>.</p>
<h5 id="examples-6"><a href="#examples-6">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;file&quot;</span>)
.<span class="ident">required</span>(<span class="bool-val">true</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;file.txt&quot;</span>,
]);
<span class="kw">let</span> <span class="ident">vals</span>: <span class="ident">String</span> <span class="op">=</span> <span class="ident">m</span>.<span class="ident">remove_one</span>(<span class="string">&quot;file&quot;</span>)
.<span class="ident">expect</span>(<span class="string">&quot;`file`is required&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="ident">vals</span>, <span class="string">&quot;file.txt&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.remove_many" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#426-431">source</a></span><h4 class="code-header">pub fn <a href="#method.remove_many" class="fnname">remove_many</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.Values.html" title="struct clap::parser::Values">Values</a>&lt;T&gt;&gt;</h4></section></summary><div class="docblock"><p>Return values of a specific option or positional argument.</p>
<p>i.e. an argument that takes multiple values at runtime.</p>
<p>Returns an error if the wrong type was used. No item will have been removed.</p>
<p>Returns <code>None</code> if the option wasnt present.</p>
<h5 id="panic-6"><a href="#panic-6">Panic</a></h5>
<p>If the argument definition and access mismatch. To handle this case programmatically, see
<a href="parser/struct.ArgMatches.html#method.try_remove_many" title="ArgMatches::try_remove_many"><code>ArgMatches::try_remove_many</code></a>.</p>
<h5 id="examples-7"><a href="#examples-7">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;file&quot;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Append</span>)
.<span class="ident">num_args</span>(<span class="number">1</span>..)
.<span class="ident">required</span>(<span class="bool-val">true</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;file1.txt&quot;</span>, <span class="string">&quot;file2.txt&quot;</span>, <span class="string">&quot;file3.txt&quot;</span>, <span class="string">&quot;file4.txt&quot;</span>,
]);
<span class="kw">let</span> <span class="ident">vals</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">m</span>.<span class="ident">remove_many</span>(<span class="string">&quot;file&quot;</span>)
.<span class="ident">expect</span>(<span class="string">&quot;`file`is required&quot;</span>)
.<span class="ident">collect</span>();
<span class="macro">assert_eq!</span>(<span class="ident">vals</span>, [<span class="string">&quot;file1.txt&quot;</span>, <span class="string">&quot;file2.txt&quot;</span>, <span class="string">&quot;file3.txt&quot;</span>, <span class="string">&quot;file4.txt&quot;</span>]);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.contains_id" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#498-500">source</a></span><h4 class="code-header">pub fn <a href="#method.contains_id" class="fnname">contains_id</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Check if values are present for the argument or group id</p>
<p><em>NOTE:</em> This will always return <code>true</code> if <a href="builder/struct.Arg.html#method.default_value"><code>default_value</code></a> has been set.
<a href="parser/struct.ArgMatches.html#method.value_source" title="ArgMatches::value_source"><code>ArgMatches::value_source</code></a> can be used to check if a value is present at runtime.</p>
<h5 id="panics"><a href="#panics">Panics</a></h5>
<p>If <code>id</code> is is not a valid argument or group name. To handle this case programmatically, see
<a href="parser/struct.ArgMatches.html#method.try_contains_id" title="ArgMatches::try_contains_id"><code>ArgMatches::try_contains_id</code></a>.</p>
<h5 id="examples-8"><a href="#examples-8">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;d&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-d&quot;</span>
]);
<span class="macro">assert!</span>(<span class="ident">m</span>.<span class="ident">contains_id</span>(<span class="string">&quot;debug&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ids" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#523-527">source</a></span><h4 class="code-header">pub fn <a href="#method.ids" class="fnname">ids</a>(&amp;self) -&gt; <a class="struct" href="parser/struct.IdsRef.html" title="struct clap::parser::IdsRef">IdsRef</a>&lt;'_&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="parser/struct.IdsRef.html" title="struct clap::parser::IdsRef">IdsRef</a>&lt;'a&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="parser/struct.IdsRef.html" title="struct clap::parser::IdsRef">IdsRef</a>&lt;'a&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.64.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="associatedtype">Item</a> = &amp;'a <a class="struct" href="struct.Id.html" title="struct clap::Id">Id</a>;</span></code></span></span></span></span></h4></section></summary><div class="docblock"><p>Iterate over <a href="builder/struct.Arg.html" title="crate::Arg"><code>Arg</code></a> and <a href="builder/struct.ArgGroup.html" title="crate::ArgGroup"><code>ArgGroup</code></a> <a href="struct.Id.html" title="crate::Id"><code>Id</code></a>s via <a href="parser/struct.ArgMatches.html#method.ids" title="ArgMatches::ids"><code>ArgMatches::ids</code></a>.</p>
<h5 id="examples-9"><a href="#examples-9">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="macro">arg!</span>(<span class="op">-</span><span class="op">-</span><span class="ident">color</span> <span class="op">&lt;</span><span class="ident">when</span><span class="op">&gt;</span>)
.<span class="ident">value_parser</span>([<span class="string">&quot;auto&quot;</span>, <span class="string">&quot;always&quot;</span>, <span class="string">&quot;never&quot;</span>]))
.<span class="ident">arg</span>(<span class="macro">arg!</span>(<span class="op">-</span><span class="op">-</span><span class="ident">config</span> <span class="op">&lt;</span><span class="ident">path</span><span class="op">&gt;</span>)
.<span class="ident">value_parser</span>(<span class="macro">value_parser!</span>(<span class="ident">std::path::PathBuf</span>)))
.<span class="ident">get_matches_from</span>([<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;--config=config.toml&quot;</span>, <span class="string">&quot;--color=auto&quot;</span>]);
<span class="macro">assert_eq!</span>(<span class="ident">m</span>.<span class="ident">ids</span>().<span class="ident">len</span>(), <span class="number">2</span>);
<span class="macro">assert_eq!</span>(
<span class="ident">m</span>.<span class="ident">ids</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">id</span><span class="op">|</span> <span class="ident">id</span>.<span class="ident">as_str</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="string">&quot;config&quot;</span>, <span class="string">&quot;color&quot;</span>]
);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.args_present" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#548-550">source</a></span><h4 class="code-header">pub fn <a href="#method.args_present" class="fnname">args_present</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Check if any args were present on the command line</p>
<h5 id="examples-10"><a href="#examples-10">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;output&quot;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>));
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">cmd</span>
.<span class="ident">try_get_matches_from_mut</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;something&quot;</span>])
.<span class="ident">unwrap</span>();
<span class="macro">assert!</span>(<span class="ident">m</span>.<span class="ident">args_present</span>());
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">cmd</span>
.<span class="ident">try_get_matches_from_mut</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>])
.<span class="ident">unwrap</span>();
<span class="macro">assert!</span>(<span class="op">!</span> <span class="ident">m</span>.<span class="ident">args_present</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.value_source" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#625-629">source</a></span><h4 class="code-header">pub fn <a href="#method.value_source" class="fnname">value_source</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="parser/enum.ValueSource.html" title="enum clap::parser::ValueSource">ValueSource</a>&gt;</h4></section></summary><div class="docblock"><p>Report where argument value came from</p>
<h5 id="panics-1"><a href="#panics-1">Panics</a></h5>
<p>If <code>id</code> is is not a valid argument or group id.</p>
<h5 id="examples-11"><a href="#examples-11">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;d&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[
<span class="string">&quot;myprog&quot;</span>, <span class="string">&quot;-d&quot;</span>
]);
<span class="macro">assert_eq!</span>(<span class="ident">m</span>.<span class="ident">value_source</span>(<span class="string">&quot;debug&quot;</span>), <span class="prelude-val">Some</span>(<span class="ident">ValueSource::CommandLine</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.index_of" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#774-778">source</a></span><h4 class="code-header">pub fn <a href="#method.index_of" class="fnname">index_of</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>The first index of that an argument showed up.</p>
<p>Indices are similar to argv indices, but are not exactly 1:1.</p>
<p>For flags (i.e. those arguments which dont 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 discrepancy, the primary difference between an argv index and clap
index, is that clap continues counting once all arguments have properly separated, 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. See <a href="parser/struct.ArgMatches.html#method.indices_of" title="ArgMatches::indices_of"><code>ArgMatches::indices_of</code></a>.</p>
<h5 id="panics-2"><a href="#panics-2">Panics</a></h5>
<p>If <code>id</code> is is not a valid argument or group id.</p>
<h5 id="examples-12"><a href="#examples-12">Examples</a></h5>
<p>The argv indices are listed in the comments below. See how they correspond to the clap
indices. Note that if its not listed in a clap index, this is because its not saved in
in an <code>ArgMatches</code> struct for querying.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;f&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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 indices: ^0 ^1 ^2 ^3</span>
<span class="comment">// clap indices: ^1 ^3</span>
<span class="macro">assert_eq!</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="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>));</code></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"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;f&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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 indices: ^0 ^1 ^2</span>
<span class="comment">// clap indices: ^1 ^3</span>
<span class="macro">assert_eq!</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="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>));</code></pre></div>
<p>Things become much more complicated, or clear if we look at a more complex combination of
flags. Lets also throw in the final option style for good measure.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;f&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag2&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;F&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag3&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;z&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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 indices: ^0 ^1 ^2</span>
<span class="comment">// clap indices: ^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="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="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="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="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>));</code></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"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;f&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag2&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;F&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag3&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;z&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-fzFoval&quot;</span>]);
<span class="comment">// ARGV indices: ^0 ^1</span>
<span class="comment">// clap indices: ^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="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="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="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="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>));</code></pre></div>
<p>The last part to mention is when values are sent in multiple groups with a <a href="builder/struct.Arg.html#method.value_delimiter">delimiter</a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">value_delimiter</span>(<span class="string">&#39;,&#39;</span>)
.<span class="ident">num_args</span>(<span class="number">1</span>..))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o=val1,val2,val3&quot;</span>]);
<span class="comment">// ARGV indices: ^0 ^1</span>
<span class="comment">// clap indices: ^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="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>));
<span class="macro">assert_eq!</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>]);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.indices_of" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#856-863">source</a></span><h4 class="code-header">pub fn <a href="#method.indices_of" class="fnname">indices_of</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.Indices.html" title="struct clap::parser::Indices">Indices</a>&lt;'_&gt;&gt;</h4></section></summary><div class="docblock"><p>All indices an argument appeared at when parsing.</p>
<p>Indices are similar to argv indices, but are not exactly 1:1.</p>
<p>For flags (i.e. those arguments which dont 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 compared to argv indices, see
<a href="parser/struct.ArgMatches.html#method.index_of"><code>ArgMatches::index_of</code></a></p>
<h5 id="panics-3"><a href="#panics-3">Panics</a></h5>
<p>If <code>id</code> is is not a valid argument or group id.</p>
<h5 id="examples-13"><a href="#examples-13">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">value_delimiter</span>(<span class="string">&#39;,&#39;</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o=val1,val2,val3&quot;</span>]);
<span class="comment">// ARGV indices: ^0 ^1</span>
<span class="comment">// clap indices: ^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="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>]);</code></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"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Append</span>))
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;flag&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;f&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Count</span>))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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 indices: ^0 ^1 ^2 ^3 ^4 ^5 ^6</span>
<span class="comment">// clap indices: ^2 ^3 ^5 ^6</span>
<span class="macro">assert_eq!</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="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">6</span>]);</code></pre></div>
<p>One final example, which is an odd case; if we <em>dont</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 theyd only receive a single
index.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myapp&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;o&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>)
.<span class="ident">num_args</span>(<span class="number">1</span>..))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</span>[<span class="string">&quot;myapp&quot;</span>, <span class="string">&quot;-o=val1,val2,val3&quot;</span>]);
<span class="comment">// ARGV indices: ^0 ^1</span>
<span class="comment">// clap indices: ^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="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>]);</code></pre></div>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-ArgMatches-1" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#867-1071">source</a></span><a href="#impl-ArgMatches-1" class="anchor"></a><h3 class="code-header in-band">impl <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="docblock"><h4 id="subcommands"><a href="#subcommands">Subcommands</a></h4></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.subcommand" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#921-923">source</a></span><h4 class="code-header">pub fn <a href="#method.subcommand" class="fnname">subcommand</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(&amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>, &amp;<a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a>)&gt;</h4></section></summary><div class="docblock"><p>The name and <code>ArgMatches</code> of the current <a href="builder/struct.Command.html#method.subcommand">subcommand</a>.</p>
<p>Subcommand values are put in a child <a href="parser/struct.ArgMatches.html" title="ArgMatches"><code>ArgMatches</code></a></p>
<p>Returns <code>None</code> if the subcommand wasnt present at runtime,</p>
<h5 id="examples-14"><a href="#examples-14">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code> <span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;git&quot;</span>)
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;clone&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;push&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">Command::new</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="prelude-val">Some</span>((<span class="string">&quot;clone&quot;</span>, <span class="ident">sub_m</span>)) =&gt; {}, <span class="comment">// clone was used</span>
<span class="prelude-val">Some</span>((<span class="string">&quot;push&quot;</span>, <span class="ident">sub_m</span>)) =&gt; {}, <span class="comment">// push was used</span>
<span class="prelude-val">Some</span>((<span class="string">&quot;commit&quot;</span>, <span class="ident">sub_m</span>)) =&gt; {}, <span class="comment">// commit was used</span>
<span class="kw">_</span> =&gt; {}, <span class="comment">// Either no subcommand or one not tested for...</span>
}</code></pre></div>
<p>Another useful scenario is when you want to support third party, or external, subcommands.
In these cases you cant 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"><code><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">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">allow_external_subcommands</span>(<span class="bool-val">true</span>)
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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="prelude-val">Some</span>((<span class="ident">external</span>, <span class="ident">sub_m</span>)) =&gt; {
<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">OsStr</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">sub_m</span>.<span class="ident">get_many</span>::<span class="op">&lt;</span><span class="ident">OsString</span><span class="op">&gt;</span>(<span class="string">&quot;&quot;</span>)
.<span class="ident">unwrap</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_os_str</span>()).<span class="ident">collect</span>();
<span class="macro">assert_eq!</span>(<span class="ident">external</span>, <span class="string">&quot;subcmd&quot;</span>);
<span class="macro">assert_eq!</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> =&gt; {},
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.remove_subcommand" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#979-981">source</a></span><h4 class="code-header">pub fn <a href="#method.remove_subcommand" class="fnname">remove_subcommand</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(<a class="struct" href="https://doc.rust-lang.org/1.64.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>, <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a>)&gt;</h4></section></summary><div class="docblock"><p>Return the name and <code>ArgMatches</code> of the current <a href="builder/struct.Command.html#method.subcommand">subcommand</a>.</p>
<p>Subcommand values are put in a child <a href="parser/struct.ArgMatches.html" title="ArgMatches"><code>ArgMatches</code></a></p>
<p>Returns <code>None</code> if the subcommand wasnt present at runtime,</p>
<h5 id="examples-15"><a href="#examples-15">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code> <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;git&quot;</span>)
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;clone&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;push&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;commit&quot;</span>))
.<span class="ident">subcommand_required</span>(<span class="bool-val">true</span>)
.<span class="ident">get_matches</span>();
<span class="kw">let</span> (<span class="ident">name</span>, <span class="ident">sub_m</span>) <span class="op">=</span> <span class="ident">app_m</span>.<span class="ident">remove_subcommand</span>().<span class="ident">expect</span>(<span class="string">&quot;required&quot;</span>);
<span class="kw">match</span> (<span class="ident">name</span>.<span class="ident">as_str</span>(), <span class="ident">sub_m</span>) {
(<span class="string">&quot;clone&quot;</span>, <span class="ident">sub_m</span>) =&gt; {}, <span class="comment">// clone was used</span>
(<span class="string">&quot;push&quot;</span>, <span class="ident">sub_m</span>) =&gt; {}, <span class="comment">// push was used</span>
(<span class="string">&quot;commit&quot;</span>, <span class="ident">sub_m</span>) =&gt; {}, <span class="comment">// commit was used</span>
(<span class="ident">name</span>, <span class="kw">_</span>) =&gt; <span class="macro">unimplemented!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">name</span>),
}</code></pre></div>
<p>Another useful scenario is when you want to support third party, or external, subcommands.
In these cases you cant 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"><code><span class="comment">// Assume there is an external subcommand named &quot;subcmd&quot;</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">allow_external_subcommands</span>(<span class="bool-val">true</span>)
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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">remove_subcommand</span>() {
<span class="prelude-val">Some</span>((<span class="ident">external</span>, <span class="kw-2">mut</span> <span class="ident">sub_m</span>)) =&gt; {
<span class="kw">let</span> <span class="ident">ext_args</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">OsString</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">sub_m</span>.<span class="ident">remove_many</span>(<span class="string">&quot;&quot;</span>)
.<span class="ident">expect</span>(<span class="string">&quot;`file`is required&quot;</span>)
.<span class="ident">collect</span>();
<span class="macro">assert_eq!</span>(<span class="ident">external</span>, <span class="string">&quot;subcmd&quot;</span>);
<span class="macro">assert_eq!</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> =&gt; {},
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.subcommand_matches" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1022-1024">source</a></span><h4 class="code-header">pub fn <a href="#method.subcommand_matches" class="fnname">subcommand_matches</a>(&amp;self, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a>&gt;</h4></section></summary><div class="docblock"><p>The <code>ArgMatches</code> for the current <a href="builder/struct.Command.html#method.subcommand">subcommand</a>.</p>
<p>Subcommand values are put in a child <a href="parser/struct.ArgMatches.html" title="ArgMatches"><code>ArgMatches</code></a></p>
<p>Returns <code>None</code> if the subcommand wasnt present at runtime,</p>
<h5 id="panics-4"><a href="#panics-4">Panics</a></h5>
<p>If <code>id</code> is is not a valid subcommand.</p>
<h5 id="examples-16"><a href="#examples-16">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;myprog&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;debug&quot;</span>)
.<span class="ident">short</span>(<span class="string">&#39;d&#39;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::SetTrue</span>)
)
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;test&quot;</span>)
.<span class="ident">arg</span>(<span class="ident">Arg::new</span>(<span class="string">&quot;opt&quot;</span>)
.<span class="ident">long</span>(<span class="string">&quot;option&quot;</span>)
.<span class="ident">action</span>(<span class="ident">ArgAction::Set</span>)))
.<span class="ident">get_matches_from</span>(<span class="macro">vec!</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="kw-2">*</span><span class="ident">app_m</span>.<span class="ident">get_one</span>::<span class="op">&lt;</span><span class="ident">bool</span><span class="op">&gt;</span>(<span class="string">&quot;debug&quot;</span>).<span class="ident">expect</span>(<span class="string">&quot;defaulted by clap&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="ident">sub_m</span>.<span class="ident">get_one</span>::<span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>(<span class="string">&quot;opt&quot;</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_str</span>()), <span class="prelude-val">Some</span>(<span class="string">&quot;val&quot;</span>));
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.subcommand_name" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1050-1052">source</a></span><h4 class="code-header">pub fn <a href="#method.subcommand_name" class="fnname">subcommand_name</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>&gt;</h4></section></summary><div class="docblock"><p>The name of the current <a href="builder/struct.Command.html#method.subcommand">subcommand</a>.</p>
<p>Returns <code>None</code> if the subcommand wasnt present at runtime,</p>
<h5 id="examples-17"><a href="#examples-17">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code> <span class="kw">let</span> <span class="ident">app_m</span> <span class="op">=</span> <span class="ident">Command::new</span>(<span class="string">&quot;git&quot;</span>)
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;clone&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">Command::new</span>(<span class="string">&quot;push&quot;</span>))
.<span class="ident">subcommand</span>(<span class="ident">Command::new</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>) =&gt; {}, <span class="comment">// clone was used</span>
<span class="prelude-val">Some</span>(<span class="string">&quot;push&quot;</span>) =&gt; {}, <span class="comment">// push was used</span>
<span class="prelude-val">Some</span>(<span class="string">&quot;commit&quot;</span>) =&gt; {}, <span class="comment">// commit was used</span>
<span class="kw">_</span> =&gt; {}, <span class="comment">// Either no subcommand or one not tested for...</span>
}</code></pre></div>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-ArgMatches-2" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1074-1224">source</a></span><a href="#impl-ArgMatches-2" class="anchor"></a><h3 class="code-header in-band">impl <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="docblock"><h4 id="advanced"><a href="#advanced">Advanced</a></h4></div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_get_one" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1076-1091">source</a></span><h4 class="code-header">pub fn <a href="#method.try_get_one" class="fnname">try_get_one</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T&gt;, <a class="enum" href="parser/enum.MatchesError.html" title="enum clap::parser::MatchesError">MatchesError</a>&gt;</h4></section></summary><div class="docblock"><p>Non-panicking version of <a href="parser/struct.ArgMatches.html#method.get_one" title="ArgMatches::get_one"><code>ArgMatches::get_one</code></a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_get_many" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1094-1110">source</a></span><h4 class="code-header">pub fn <a href="#method.try_get_many" class="fnname">try_get_many</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.ValuesRef.html" title="struct clap::parser::ValuesRef">ValuesRef</a>&lt;'_, T&gt;&gt;, <a class="enum" href="parser/enum.MatchesError.html" title="enum clap::parser::MatchesError">MatchesError</a>&gt;</h4></section></summary><div class="docblock"><p>Non-panicking version of <a href="parser/struct.ArgMatches.html#method.get_many" title="ArgMatches::get_many"><code>ArgMatches::get_many</code></a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_get_raw" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1131-1143">source</a></span><h4 class="code-header">pub fn <a href="#method.try_get_raw" class="fnname">try_get_raw</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.RawValues.html" title="struct clap::parser::RawValues">RawValues</a>&lt;'_&gt;&gt;, <a class="enum" href="parser/enum.MatchesError.html" title="enum clap::parser::MatchesError">MatchesError</a>&gt;</h4></section></summary><div class="docblock"><p>Non-panicking version of <a href="parser/struct.ArgMatches.html#method.get_raw" title="ArgMatches::get_raw"><code>ArgMatches::get_raw</code></a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_remove_one" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1165-1177">source</a></span><h4 class="code-header">pub fn <a href="#method.try_remove_one" class="fnname">try_remove_one</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;, <a class="enum" href="parser/enum.MatchesError.html" title="enum clap::parser::MatchesError">MatchesError</a>&gt;</h4></section></summary><div class="docblock"><p>Non-panicking version of <a href="parser/struct.ArgMatches.html#method.remove_one" title="ArgMatches::remove_one"><code>ArgMatches::remove_one</code></a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_remove_many" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1180-1196">source</a></span><h4 class="code-header">pub fn <a href="#method.try_remove_many" class="fnname">try_remove_many</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.64.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="parser/struct.Values.html" title="struct clap::parser::Values">Values</a>&lt;T&gt;&gt;, <a class="enum" href="parser/enum.MatchesError.html" title="enum clap::parser::MatchesError">MatchesError</a>&gt;</h4></section></summary><div class="docblock"><p>Non-panicking version of <a href="parser/struct.ArgMatches.html#method.remove_many" title="ArgMatches::remove_many"><code>ArgMatches::remove_many</code></a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_contains_id" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#1218-1223">source</a></span><h4 class="code-header">pub fn <a href="#method.try_contains_id" class="fnname">try_contains_id</a>(&amp;self, id: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.bool.html">bool</a>, <a class="enum" href="parser/enum.MatchesError.html" title="enum clap::parser::MatchesError">MatchesError</a>&gt;</h4></section></summary><div class="docblock"><p>Non-panicking version of <a href="parser/struct.ArgMatches.html#method.contains_id" title="ArgMatches::contains_id"><code>ArgMatches::contains_id</code></a></p>
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-Clone-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&amp;self) -&gt; <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h4></section></summary><div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/clone.rs.html#132-134">source</a></span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/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/1.64.0/std/primitive.reference.html">&amp;</a>Self)</h4></section></summary><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.64.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-Debug-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.64.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Default-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-Default-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.default" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/default/trait.Default.html#tymethod.default" class="fnname">default</a>() -&gt; <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h4></section></summary><div class='docblock'><p>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.64.0/core/default/trait.Default.html#tymethod.default">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CArgMatches%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-PartialEq%3CArgMatches%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a>&gt; for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&amp;self, other: &amp;<a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>. <a href="https://doc.rust-lang.org/1.64.0/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#method.ne" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&amp;self, other: &amp;<a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></details></div></details><section id="impl-Eq-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-Eq-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section><section id="impl-StructuralEq-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-StructuralEq-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.StructuralEq.html" title="trait core::marker::StructuralEq">StructuralEq</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section><section id="impl-StructuralPartialEq-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/clap/parser/matches/arg_matches.rs.html#65">source</a></span><a href="#impl-StructuralPartialEq-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></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"><section id="impl-RefUnwindSafe-for-ArgMatches" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl !<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section><section id="impl-Send-for-ArgMatches" class="impl has-srclink"><a href="#impl-Send-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section><section id="impl-Sync-for-ArgMatches" class="impl has-srclink"><a href="#impl-Sync-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section><section id="impl-Unpin-for-ArgMatches" class="impl has-srclink"><a href="#impl-Unpin-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section><section id="impl-UnwindSafe-for-ArgMatches" class="impl has-srclink"><a href="#impl-UnwindSafe-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl !<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="parser/struct.ArgMatches.html" title="struct clap::parser::ArgMatches">ArgMatches</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/any.rs.html#203">source</a></span><a href="#impl-Any-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/any.rs.html#204">source</a></span><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.64.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/borrow.rs.html#209">source</a></span><a href="#impl-Borrow%3CT%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/borrow.rs.html#211">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T</h4></section></summary><div class='docblock'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.64.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/borrow.rs.html#218">source</a></span><a href="#impl-BorrowMut%3CT%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/borrow.rs.html#219">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/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/1.64.0/std/primitive.reference.html">&amp;mut </a>T</h4></section></summary><div class='docblock'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.64.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#557">source</a></span><a href="#impl-From%3CT%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#559">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#541">source</a></span><a href="#impl-Into%3CU%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#549">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.64.0/core/convert/trait.From.html" title="From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/alloc/borrow.rs.html#83">source</a></span><a href="#impl-ToOwned-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.64.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'><p>The resulting type after obtaining ownership.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/alloc/borrow.rs.html#88">source</a></span><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&amp;self) -&gt; T</h4></section></summary><div class='docblock'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.64.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/alloc/borrow.rs.html#92">source</a></span><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/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/1.64.0/std/primitive.reference.html">&amp;mut </a>T)</h4></section></summary><div class='docblock'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.64.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#598">source</a></span><a href="#impl-TryFrom%3CU%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#604">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/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/1.64.0/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/1.64.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'><p>Performs the conversion.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-ArgMatches" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#583">source</a></span><a href="#impl-TryInto%3CU%3E-for-ArgMatches" class="anchor"></a><h3 class="code-header in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.64.0/src/core/convert/mod.rs.html#589">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/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/1.64.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.64.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'><p>Performs the conversion.</p>
</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="clap" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>