mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
chore(docs): rebuild documentation
This commit is contained in:
parent
489be5427e
commit
02aa217612
14 changed files with 513 additions and 40 deletions
|
@ -47,7 +47,7 @@
|
|||
<div class='docblock'>
|
||||
<h1 id="clap" class='section-header'><a
|
||||
href="#clap">clap</a></h1>
|
||||
<p><img src="https://travis-ci.org/kbknapp/clap-rs.svg?branch=master" alt="Travis-CI"> <a href="https://gitter.im/kbknapp/clap-rs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/kbknapp/clap-rs"></a></p>
|
||||
<p><img src="https://travis-ci.org/kbknapp/clap-rs.svg?branch=master" alt="Travis-CI"> <a href="https://crates.io/crates/clap"><img src="http://meritbadge.herokuapp.com/clap" alt=""></a> <a href="https://gitter.im/kbknapp/clap-rs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/kbknapp/clap-rs"></a></p>
|
||||
|
||||
<p>Command Line Argument Parser for Rust</p>
|
||||
|
||||
|
@ -114,7 +114,7 @@
|
|||
<li><strong>Specific Value Sets</strong>: Positional or Option Arguments can optionally define a specific set of allowed values (i.e. imagine a <code>--mode</code> option which may <em>only</em> have one of two values <code>fast</code> or <code>slow</code> such as <code>--mode fast</code> or <code>--mode slow</code>)</li>
|
||||
<li><strong>Default Values</strong>: Although not specifically provided by <code>clap</code> you can achieve this exact functionality from Rust's <code>Option<&str>.unwrap_or("some default")</code> method (or <code>Result<T,String>.unwrap_or(T)</code> when using typed values)</li>
|
||||
<li><strong>Automatic Version from Cargo.toml</strong>: <code>clap</code> is fully compatible with Rust's <code>env!()</code> macro for automatically setting the version of your application to the version in your Cargo.toml. See <code>examples/09_AutoVersion.rs</code> for how to do this (Thanks to <a href="https://github.com/jhelwig">jhelwig</a> for pointing this out)</li>
|
||||
<li><strong>Typed Values</strong>: You can use several convenience macros provided by <code>clap</code> to get typed values (i.e. <code>i32</code>, <code>u8</code>, etc.) from positional or option arguments so long as the type you request implements <code>std::str::FromStr</code> See the <code>examples/12_TypedValues.rs</code> or the <a href="http://kbknapp.github.io/clap-rs/docs/clap/index.html">documentation</a> for more information.</li>
|
||||
<li><strong>Typed Values</strong>: You can use several convenience macros provided by <code>clap</code> to get typed values (i.e. <code>i32</code>, <code>u8</code>, etc.) from positional or option arguments so long as the type you request implements <code>std::str::FromStr</code> See the <code>examples/12_TypedValues.rs</code>. You can also use <code>clap</code>s <code>simple_enum!</code> macro to create an enum with variants that automatically implements <code>std::str::FromStr</code> in order to use with the other <code>clap</code> macros. See <code>examples/13a_EnumValuesAutomatic.rs</code> for details.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="quick-example" class='section-header'><a
|
||||
|
@ -363,6 +363,14 @@ SUBCOMMANDS:
|
|||
<p><code>clap</code> is licensed under the MIT license. Please the LICENSE-MIT file in this repository for more information.</p>
|
||||
</div><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td><a class='stability Unmarked' title='No stability level'></a><a class='macro' href='macro.arg_enum!.html'
|
||||
title='clap::arg_enum!'>arg_enum!</a></td>
|
||||
<td class='docblock short'><p>Convenience macro to generate more complete enums with variants to be used as a type when parsing
|
||||
arguments.</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a class='stability Unmarked' title='No stability level'></a><a class='macro' href='macro.simple_enum!.html'
|
||||
title='clap::simple_enum!'>simple_enum!</a></td>
|
||||
|
|
211
docs/clap/macro.arg_enum!.html
Normal file
211
docs/clap/macro.arg_enum!.html
Normal file
|
@ -0,0 +1,211 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="generator" content="rustdoc">
|
||||
<meta name="description" content="API documentation for the Rust `arg_enum!` macro in crate `clap`.">
|
||||
<meta name="keywords" content="rust, rustlang, rust-lang, arg_enum!">
|
||||
|
||||
<title>clap::arg_enum! - Rust</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../main.css">
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
<body class="rustdoc">
|
||||
<!--[if lte IE 8]>
|
||||
<div class="warning">
|
||||
This old browser is unsupported and will most likely display funky
|
||||
things.
|
||||
</div>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
|
||||
<section class="sidebar">
|
||||
|
||||
<p class='location'><a href='index.html'>clap</a></p><script>window.sidebarCurrent = {name: 'arg_enum!', ty: 'macro', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||||
</section>
|
||||
|
||||
<nav class="sub">
|
||||
<form class="search-form js-only">
|
||||
<div class="search-container">
|
||||
<input class="search-input" name="search"
|
||||
autocomplete="off"
|
||||
placeholder="Click or press 'S' to search, '?' for more options..."
|
||||
type="search">
|
||||
</div>
|
||||
</form>
|
||||
</nav>
|
||||
|
||||
<section id='main' class="content macro">
|
||||
<h1 class='fqn'><span class='in-band'><a href='index.html'>clap</a>::<wbr><a class='macro' href=''>arg_enum!</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-10467' href='../src/clap/macros.rs.html#297-384'>[src]</a></span></h1>
|
||||
<pre class='rust macro'>
|
||||
<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>arg_enum</span> {
|
||||
(<span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>:<span class='ident'>ident</span>),<span class='op'>+</span>)]</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>,)<span class='op'>+</span>)]</span>
|
||||
<span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>:<span class='ident'>ident</span>),<span class='op'>+</span>)]</span> <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>,)<span class='op'>+</span>)]</span>
|
||||
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</pre>
|
||||
<div class='docblock'><p>Convenience macro to generate more complete enums with variants to be used as a type when parsing
|
||||
arguments.</p>
|
||||
|
||||
<p>These enums support pub (or not) and use of the #[derive()] traits</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
<span class='macro'>arg_enum</span><span class='macro'>!</span>{
|
||||
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span>
|
||||
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Foo</span> {
|
||||
<span class='ident'>Bar</span>,
|
||||
<span class='ident'>Baz</span>,
|
||||
<span class='ident'>Qux</span>
|
||||
}
|
||||
}
|
||||
<span class='comment'>// Foo enum can now be used via Foo::Bar, or Foo::Baz, etc</span>
|
||||
<span class='comment'>// and implements std::str::FromStr to use with the value_t! macros</span>
|
||||
<span class='kw'>fn</span> <span class='ident'>main</span>() {
|
||||
<span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"app"</span>)
|
||||
.<span class='ident'>arg_from_usage</span>(<span class='string'>"<foo> 'the foo'"</span>)
|
||||
.<span class='ident'>get_matches</span>();
|
||||
<span class='kw'>let</span> <span class='ident'>f</span> <span class='op'>=</span> <span class='macro'>value_t_or_exit</span><span class='macro'>!</span>(<span class='ident'>m</span>.<span class='ident'>value_of</span>(<span class='string'>"foo"</span>), <span class='ident'>Foo</span>);
|
||||
|
||||
<span class='comment'>// Use f like any other Foo variant...</span>
|
||||
}
|
||||
</pre>
|
||||
</div></section>
|
||||
<section id='search' class="content hidden"></section>
|
||||
|
||||
<section class="footer"></section>
|
||||
|
||||
<div id="help" class="hidden">
|
||||
<div class="shortcuts">
|
||||
<h1>Keyboard shortcuts</h1>
|
||||
<dl>
|
||||
<dt>?</dt>
|
||||
<dd>Show this help dialog</dd>
|
||||
<dt>S</dt>
|
||||
<dd>Focus the search field</dd>
|
||||
<dt>⇤</dt>
|
||||
<dd>Move up in search results</dd>
|
||||
<dt>⇥</dt>
|
||||
<dd>Move down in search results</dd>
|
||||
<dt>⏎</dt>
|
||||
<dd>Go to active search result</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="infos">
|
||||
<h1>Search tricks</h1>
|
||||
<p>
|
||||
Prefix searches with a type followed by a colon (e.g.
|
||||
<code>fn:</code>) to restrict the search to a given type.
|
||||
</p>
|
||||
<p>
|
||||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||||
<code>struct</code>, <code>enum</code>,
|
||||
<code>trait</code>, <code>typedef</code> (or
|
||||
<code>tdef</code>).
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
window.rootPath = "../";
|
||||
window.currentCrate = "clap";
|
||||
window.playgroundUrl = "";
|
||||
</script>
|
||||
<script src="../jquery.js"></script>
|
||||
<script src="../main.js"></script>
|
||||
|
||||
<script async src="../search-index.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content macro">
|
||||
<h1 class='fqn'><span class='in-band'><a href='index.html'>clap</a>::<wbr><a class='macro' href=''>simple_enum!</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-10430' href='../src/clap/macros.rs.html#240-257'>[src]</a></span></h1>
|
||||
</span><a id='src-10466' href='../src/clap/macros.rs.html#241-263'>[src]</a></span></h1>
|
||||
<pre class='rust macro'>
|
||||
<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>simple_enum</span> {
|
||||
(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> <span class='op'>=></span> $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span>) <span class='op'>=></span> {
|
||||
|
@ -51,13 +51,18 @@
|
|||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>str</span>;
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='string'>"no match"</span>)
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content macro">
|
||||
<h1 class='fqn'><span class='in-band'><a href='index.html'>clap</a>::<wbr><a class='macro' href=''>value_t!</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-10428' href='../src/clap/macros.rs.html#84-118'>[src]</a></span></h1>
|
||||
</span><a id='src-10464' href='../src/clap/macros.rs.html#84-118'>[src]</a></span></h1>
|
||||
<pre class='rust macro'>
|
||||
<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>value_t</span> {
|
||||
(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>m</span>:<span class='ident'>ident</span>.<span class='ident'>value_of</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>expr</span>), <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>:<span class='ident'>ty</span>) <span class='op'>=></span> {
|
||||
|
@ -65,8 +65,8 @@
|
|||
<span class='kw'>for</span> <span class='ident'>pv</span> <span class='kw'>in</span> <span class='ident'>v</span> {
|
||||
<span class='kw'>match</span> <span class='ident'>pv</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span><span class='op'>></span>() {
|
||||
<span class='prelude-val'>Ok</span>(<span class='ident'>rv</span>) <span class='op'>=></span> <span class='ident'>tmp</span>.<span class='ident'>push</span>(<span class='ident'>rv</span>),
|
||||
<span class='prelude-val'>Err</span>(_) <span class='op'>=></span> {
|
||||
<span class='ident'>err</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}"</span>,<span class='ident'>pv</span>,<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>)));
|
||||
<span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> {
|
||||
<span class='ident'>err</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}\n{}"</span>,<span class='ident'>pv</span>,<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>),<span class='ident'>e</span>));
|
||||
<span class='kw'>break</span>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content macro">
|
||||
<h1 class='fqn'><span class='in-band'><a href='index.html'>clap</a>::<wbr><a class='macro' href=''>value_t_or_exit!</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-10429' href='../src/clap/macros.rs.html#166-215'>[src]</a></span></h1>
|
||||
</span><a id='src-10465' href='../src/clap/macros.rs.html#166-216'>[src]</a></span></h1>
|
||||
<pre class='rust macro'>
|
||||
<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>value_t_or_exit</span> {
|
||||
(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>m</span>:<span class='ident'>ident</span>.<span class='ident'>value_of</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>expr</span>), <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>:<span class='ident'>ty</span>) <span class='op'>=></span> {
|
||||
|
@ -51,10 +51,11 @@
|
|||
<span class='prelude-val'>Some</span>(<span class='ident'>v</span>) <span class='op'>=></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>v</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span><span class='op'>></span>() {
|
||||
<span class='prelude-val'>Ok</span>(<span class='ident'>val</span>) <span class='op'>=></span> <span class='ident'>val</span>,
|
||||
<span class='prelude-val'>Err</span>(_) <span class='op'>=></span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}\n{}\nPlease re-run with --help for more information"</span>,
|
||||
<span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}\n{}\n{}\nPlease re-run with --help for more information"</span>,
|
||||
<span class='ident'>v</span>,
|
||||
<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>),
|
||||
<span class='ident'>e</span>,
|
||||
<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>m</span>.<span class='ident'>usage</span>());
|
||||
::<span class='ident'>std</span>::<span class='ident'>process</span>::<span class='ident'>exit</span>(<span class='number'>1</span>);
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
initSidebarItems({"macro":[["simple_enum!","Convenience macro generated a simple enum with variants to be used as a type when parsing arguments."],["value_t!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr` This macro returns a `Result<T,String>` which allows you as the developer to decide what you'd like to do on a failed parse. There are two types of errors, parse failures and those where the argument wasn't present (such as a non-required argument). "],["value_t_or_exit!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr` This macro returns a `T` or `Vec<T>` or exits with a usage string upon failure. This removes some of the boiler plate to handle failures from value_t! above. "]],"struct":[["App","Used to create a representation of a command line program and all possible command line arguments for parsing at runtime."],["Arg","The abstract representation of a command line argument used by the consumer of the library. Used to set all the options and relationships that define a valid argument for the program."],["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime by the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct."],["SubCommand","The abstract representation of a command line subcommand used by the consumer of the library."]]});
|
||||
initSidebarItems({"struct":[["App","Used to create a representation of a command line program and all possible command line arguments for parsing at runtime."],["Arg","The abstract representation of a command line argument used by the consumer of the library. Used to set all the options and relationships that define a valid argument for the program."],["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime by the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct."],["SubCommand","The abstract representation of a command line subcommand used by the consumer of the library."]],"macro":[["arg_enum!","Convenience macro to generate more complete enums with variants to be used as a type when parsing arguments."],["simple_enum!","Convenience macro generated a simple enum with variants to be used as a type when parsing arguments."],["value_t!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr` This macro returns a `Result<T,String>` which allows you as the developer to decide what you'd like to do on a failed parse. There are two types of errors, parse failures and those where the argument wasn't present (such as a non-required argument). "],["value_t_or_exit!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr` This macro returns a `T` or `Vec<T>` or exits with a usage string upon failure. This removes some of the boiler plate to handle failures from value_t! above. "]]});
|
|
@ -1 +1 @@
|
|||
{"name":"clap","counts":{"deprecated":0,"unstable":0,"stable":0,"unmarked":48},"submodules":[]}
|
||||
{"name":"clap","counts":{"deprecated":0,"unstable":0,"stable":0,"unmarked":49},"submodules":[]}
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content struct">
|
||||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>Arg</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-8395' href='../src/clap/args/arg.rs.html#31-76'>[src]</a></span></h1>
|
||||
</span><a id='src-8427' href='../src/clap/args/arg.rs.html#31-76'>[src]</a></span></h1>
|
||||
<pre class='rust struct'>pub struct Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||
// some fields omitted
|
||||
}</pre><div class='docblock'><p>The abstract representation of a command line argument used by the consumer of the library.
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content struct">
|
||||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>ArgMatches</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-9253' href='../src/clap/args/argmatches.rs.html#57-68'>[src]</a></span></h1>
|
||||
</span><a id='src-9287' href='../src/clap/args/argmatches.rs.html#57-68'>[src]</a></span></h1>
|
||||
<pre class='rust struct'>pub struct ArgMatches<'a> {
|
||||
// some fields omitted
|
||||
}</pre><div class='docblock'><p>Used to get information about the arguments that where supplied to the program at runtime by
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content struct">
|
||||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>SubCommand</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-9744' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
|
||||
</span><a id='src-9778' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
|
||||
<pre class='rust struct'>pub struct SubCommand<'a> {
|
||||
pub name: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>,
|
||||
pub matches: <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a><'a>,
|
||||
|
|
20
docs/main.js
20
docs/main.js
|
@ -78,11 +78,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (e.which === 191) { // question mark
|
||||
if (e.shiftKey && $('#help').hasClass('hidden')) {
|
||||
e.preventDefault();
|
||||
$('#help').removeClass('hidden');
|
||||
}
|
||||
if (e.which === 191 && $('#help').hasClass('hidden')) { // question mark
|
||||
e.preventDefault();
|
||||
$('#help').removeClass('hidden');
|
||||
} else if (e.which === 27) { // esc
|
||||
if (!$('#help').hasClass('hidden')) {
|
||||
e.preventDefault();
|
||||
|
@ -470,8 +468,6 @@
|
|||
if ($active.length) {
|
||||
document.location.href = $active.find('a').prop('href');
|
||||
}
|
||||
} else {
|
||||
$active.removeClass('highlighted');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -717,12 +713,10 @@
|
|||
if (crates[i] == window.currentCrate) {
|
||||
klass += ' current';
|
||||
}
|
||||
if (rawSearchIndex[crates[i]].items[0]) {
|
||||
var desc = rawSearchIndex[crates[i]].items[0][3];
|
||||
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
|
||||
'title': plainSummaryLine(desc),
|
||||
'class': klass}).text(crates[i]));
|
||||
}
|
||||
var desc = rawSearchIndex[crates[i]].items[0][3];
|
||||
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
|
||||
'title': plainSummaryLine(desc),
|
||||
'class': klass}).text(crates[i]));
|
||||
}
|
||||
sidebar.append(div);
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -953,7 +953,7 @@
|
|||
<span class='comment'>// DOCS</span>
|
||||
<span class='doccomment'>//! # clap</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
<span class='doccomment'>//! ![Travis-CI](https://travis-ci.org/kbknapp/clap-rs.svg?branch=master) [![Join the chat at https://gitter.im/kbknapp/clap-rs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbknapp/clap-rs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)</span>
|
||||
<span class='doccomment'>//! ![Travis-CI](https://travis-ci.org/kbknapp/clap-rs.svg?branch=master) [![](http://meritbadge.herokuapp.com/clap)](https://crates.io/crates/clap) [![Join the chat at https://gitter.im/kbknapp/clap-rs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbknapp/clap-rs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
<span class='doccomment'>//! Command Line Argument Parser for Rust</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
|
@ -998,7 +998,7 @@
|
|||
<span class='doccomment'>//! * **Specific Value Sets**: Positional or Option Arguments can optionally define a specific set of allowed values (i.e. imagine a `--mode` option which may *only* have one of two values `fast` or `slow` such as `--mode fast` or `--mode slow`)</span>
|
||||
<span class='doccomment'>//! * **Default Values**: Although not specifically provided by `clap` you can achieve this exact functionality from Rust's `Option<&str>.unwrap_or("some default")` method (or `Result<T,String>.unwrap_or(T)` when using typed values)</span>
|
||||
<span class='doccomment'>//! * **Automatic Version from Cargo.toml**: `clap` is fully compatible with Rust's `env!()` macro for automatically setting the version of your application to the version in your Cargo.toml. See `examples/09_AutoVersion.rs` for how to do this (Thanks to [jhelwig](https://github.com/jhelwig) for pointing this out)</span>
|
||||
<span class='doccomment'>//! * **Typed Values**: You can use several convenience macros provided by `clap` to get typed values (i.e. `i32`, `u8`, etc.) from positional or option arguments so long as the type you request implements `std::str::FromStr` See the `examples/12_TypedValues.rs` or the [documentation](http://kbknapp.github.io/clap-rs/docs/clap/index.html) for more information.</span>
|
||||
<span class='doccomment'>//! * **Typed Values**: You can use several convenience macros provided by `clap` to get typed values (i.e. `i32`, `u8`, etc.) from positional or option arguments so long as the type you request implements `std::str::FromStr` See the `examples/12_TypedValues.rs`. You can also use `clap`s `simple_enum!` macro to create an enum with variants that automatically implements `std::str::FromStr` in order to use with the other `clap` macros. See `examples/13a_EnumValuesAutomatic.rs` for details.</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
<span class='doccomment'>//! ## Quick Example</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
|
|
|
@ -297,6 +297,133 @@
|
|||
<span id="255">255</span>
|
||||
<span id="256">256</span>
|
||||
<span id="257">257</span>
|
||||
<span id="258">258</span>
|
||||
<span id="259">259</span>
|
||||
<span id="260">260</span>
|
||||
<span id="261">261</span>
|
||||
<span id="262">262</span>
|
||||
<span id="263">263</span>
|
||||
<span id="264">264</span>
|
||||
<span id="265">265</span>
|
||||
<span id="266">266</span>
|
||||
<span id="267">267</span>
|
||||
<span id="268">268</span>
|
||||
<span id="269">269</span>
|
||||
<span id="270">270</span>
|
||||
<span id="271">271</span>
|
||||
<span id="272">272</span>
|
||||
<span id="273">273</span>
|
||||
<span id="274">274</span>
|
||||
<span id="275">275</span>
|
||||
<span id="276">276</span>
|
||||
<span id="277">277</span>
|
||||
<span id="278">278</span>
|
||||
<span id="279">279</span>
|
||||
<span id="280">280</span>
|
||||
<span id="281">281</span>
|
||||
<span id="282">282</span>
|
||||
<span id="283">283</span>
|
||||
<span id="284">284</span>
|
||||
<span id="285">285</span>
|
||||
<span id="286">286</span>
|
||||
<span id="287">287</span>
|
||||
<span id="288">288</span>
|
||||
<span id="289">289</span>
|
||||
<span id="290">290</span>
|
||||
<span id="291">291</span>
|
||||
<span id="292">292</span>
|
||||
<span id="293">293</span>
|
||||
<span id="294">294</span>
|
||||
<span id="295">295</span>
|
||||
<span id="296">296</span>
|
||||
<span id="297">297</span>
|
||||
<span id="298">298</span>
|
||||
<span id="299">299</span>
|
||||
<span id="300">300</span>
|
||||
<span id="301">301</span>
|
||||
<span id="302">302</span>
|
||||
<span id="303">303</span>
|
||||
<span id="304">304</span>
|
||||
<span id="305">305</span>
|
||||
<span id="306">306</span>
|
||||
<span id="307">307</span>
|
||||
<span id="308">308</span>
|
||||
<span id="309">309</span>
|
||||
<span id="310">310</span>
|
||||
<span id="311">311</span>
|
||||
<span id="312">312</span>
|
||||
<span id="313">313</span>
|
||||
<span id="314">314</span>
|
||||
<span id="315">315</span>
|
||||
<span id="316">316</span>
|
||||
<span id="317">317</span>
|
||||
<span id="318">318</span>
|
||||
<span id="319">319</span>
|
||||
<span id="320">320</span>
|
||||
<span id="321">321</span>
|
||||
<span id="322">322</span>
|
||||
<span id="323">323</span>
|
||||
<span id="324">324</span>
|
||||
<span id="325">325</span>
|
||||
<span id="326">326</span>
|
||||
<span id="327">327</span>
|
||||
<span id="328">328</span>
|
||||
<span id="329">329</span>
|
||||
<span id="330">330</span>
|
||||
<span id="331">331</span>
|
||||
<span id="332">332</span>
|
||||
<span id="333">333</span>
|
||||
<span id="334">334</span>
|
||||
<span id="335">335</span>
|
||||
<span id="336">336</span>
|
||||
<span id="337">337</span>
|
||||
<span id="338">338</span>
|
||||
<span id="339">339</span>
|
||||
<span id="340">340</span>
|
||||
<span id="341">341</span>
|
||||
<span id="342">342</span>
|
||||
<span id="343">343</span>
|
||||
<span id="344">344</span>
|
||||
<span id="345">345</span>
|
||||
<span id="346">346</span>
|
||||
<span id="347">347</span>
|
||||
<span id="348">348</span>
|
||||
<span id="349">349</span>
|
||||
<span id="350">350</span>
|
||||
<span id="351">351</span>
|
||||
<span id="352">352</span>
|
||||
<span id="353">353</span>
|
||||
<span id="354">354</span>
|
||||
<span id="355">355</span>
|
||||
<span id="356">356</span>
|
||||
<span id="357">357</span>
|
||||
<span id="358">358</span>
|
||||
<span id="359">359</span>
|
||||
<span id="360">360</span>
|
||||
<span id="361">361</span>
|
||||
<span id="362">362</span>
|
||||
<span id="363">363</span>
|
||||
<span id="364">364</span>
|
||||
<span id="365">365</span>
|
||||
<span id="366">366</span>
|
||||
<span id="367">367</span>
|
||||
<span id="368">368</span>
|
||||
<span id="369">369</span>
|
||||
<span id="370">370</span>
|
||||
<span id="371">371</span>
|
||||
<span id="372">372</span>
|
||||
<span id="373">373</span>
|
||||
<span id="374">374</span>
|
||||
<span id="375">375</span>
|
||||
<span id="376">376</span>
|
||||
<span id="377">377</span>
|
||||
<span id="378">378</span>
|
||||
<span id="379">379</span>
|
||||
<span id="380">380</span>
|
||||
<span id="381">381</span>
|
||||
<span id="382">382</span>
|
||||
<span id="383">383</span>
|
||||
<span id="384">384</span>
|
||||
</pre><pre class='rust '>
|
||||
<span class='comment'>// De-duplication macro used in src/app.rs</span>
|
||||
<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>get_help</span> {
|
||||
|
@ -401,8 +528,8 @@
|
|||
<span class='kw'>for</span> <span class='ident'>pv</span> <span class='kw'>in</span> <span class='ident'>v</span> {
|
||||
<span class='kw'>match</span> <span class='ident'>pv</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span><span class='op'>></span>() {
|
||||
<span class='prelude-val'>Ok</span>(<span class='ident'>rv</span>) <span class='op'>=></span> <span class='ident'>tmp</span>.<span class='ident'>push</span>(<span class='ident'>rv</span>),
|
||||
<span class='prelude-val'>Err</span>(_) <span class='op'>=></span> {
|
||||
<span class='ident'>err</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}"</span>,<span class='ident'>pv</span>,<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>)));
|
||||
<span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> {
|
||||
<span class='ident'>err</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}\n{}"</span>,<span class='ident'>pv</span>,<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>),<span class='ident'>e</span>));
|
||||
<span class='kw'>break</span>
|
||||
}
|
||||
}
|
||||
|
@ -469,10 +596,11 @@
|
|||
<span class='prelude-val'>Some</span>(<span class='ident'>v</span>) <span class='op'>=></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>v</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span><span class='op'>></span>() {
|
||||
<span class='prelude-val'>Ok</span>(<span class='ident'>val</span>) <span class='op'>=></span> <span class='ident'>val</span>,
|
||||
<span class='prelude-val'>Err</span>(_) <span class='op'>=></span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}\n{}\nPlease re-run with --help for more information"</span>,
|
||||
<span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} isn't a valid {}\n{}\n{}\nPlease re-run with --help for more information"</span>,
|
||||
<span class='ident'>v</span>,
|
||||
<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>),
|
||||
<span class='ident'>e</span>,
|
||||
<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>m</span>.<span class='ident'>usage</span>());
|
||||
::<span class='ident'>std</span>::<span class='ident'>process</span>::<span class='ident'>exit</span>(<span class='number'>1</span>);
|
||||
}
|
||||
|
@ -543,13 +671,139 @@
|
|||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>str</span>;
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='string'>"no match"</span>)
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
<span class='doccomment'>/// Convenience macro to generate more complete enums with variants to be used as a type when parsing</span>
|
||||
<span class='doccomment'>/// arguments.</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// These enums support pub (or not) and use of the #[derive()] traits</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// # Example</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// ```no_run</span>
|
||||
<span class='doccomment'>/// # #[macro_use]</span>
|
||||
<span class='doccomment'>/// # extern crate clap;</span>
|
||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||
<span class='doccomment'>/// arg_enum!{</span>
|
||||
<span class='doccomment'>/// #[derive(Debug)]</span>
|
||||
<span class='doccomment'>/// pub enum Foo {</span>
|
||||
<span class='doccomment'>/// Bar,</span>
|
||||
<span class='doccomment'>/// Baz,</span>
|
||||
<span class='doccomment'>/// Qux</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// // Foo enum can now be used via Foo::Bar, or Foo::Baz, etc</span>
|
||||
<span class='doccomment'>/// // and implements std::str::FromStr to use with the value_t! macros</span>
|
||||
<span class='doccomment'>/// fn main() {</span>
|
||||
<span class='doccomment'>/// let m = App::new("app")</span>
|
||||
<span class='doccomment'>/// .arg_from_usage("<foo> 'the foo'")</span>
|
||||
<span class='doccomment'>/// .get_matches();</span>
|
||||
<span class='doccomment'>/// let f = value_t_or_exit!(m.value_of("foo"), Foo);</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// // Use f like any other Foo variant...</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// ```</span>
|
||||
<span class='attribute'>#[<span class='ident'>macro_export</span>]</span>
|
||||
<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>arg_enum</span> {
|
||||
(<span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>:<span class='ident'>ident</span>),<span class='op'>+</span>)]</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>,)<span class='op'>+</span>)]</span>
|
||||
<span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>:<span class='ident'>ident</span>),<span class='op'>+</span>)]</span> <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>ident</span> { $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>:<span class='ident'>ident</span>),<span class='op'>+</span> } ) <span class='op'>=></span> {
|
||||
<span class='attribute'>#[<span class='ident'>derive</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>,)<span class='op'>+</span>)]</span>
|
||||
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
$(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),<span class='op'>+</span>
|
||||
}
|
||||
|
||||
<span class='kw'>impl</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span> {
|
||||
<span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>String</span>;
|
||||
|
||||
<span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='kw'>Self</span>,<span class='op'><</span><span class='kw'>Self</span> <span class='kw'>as</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span><span class='op'>></span>::<span class='prelude-val'>Err</span><span class='op'>></span> {
|
||||
<span class='kw'>match</span> <span class='ident'>s</span> {
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>({
|
||||
<span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
$(<span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>v</span>),)<span class='op'>+</span>
|
||||
];
|
||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"valid:{}"</span>, <span class='ident'>v</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(),<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>i</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>, <span class='ident'>i</span>)[..]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue