edlang/winnow/combinator/index.html
2024-05-07 06:31:16 +00:00

184 lines
46 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of parsers and combinators"><title>winnow::combinator - Rust</title><script> if (window.location.protocol !== "file:") document.write(`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2">`)</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-e935ef01ae1c1829.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="winnow" data-themes="" data-resource-suffix="" data-rustdoc-version="1.78.0 (9b00956e5 2024-04-29)" data-channel="1.78.0" data-search-js="search-42d8da7a6b9792c2.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-4c98445ec4002617.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-12cf3b4f4f9dc36d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-04d5337699b92874.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod"><!--[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" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../winnow/index.html">winnow</a><span class="version">0.6.8</span></h2></div><h2 class="location"><a href="#">Module combinator</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></section><h2><a href="../index.html">In crate winnow</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../winnow/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Module <a href="../index.html">winnow</a>::<wbr><a class="mod" href="#">combinator</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/winnow/combinator/mod.rs.html#1-176">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="list-of-parsers-and-combinators"><a class="doc-anchor" href="#list-of-parsers-and-combinators">§</a>List of parsers and combinators</h2>
<p><strong>Note</strong>: this list is meant to provide a nicer way to find a parser than reading through the documentation on docs.rs. Function combinators are organized in module so they are a bit easier to find.</p>
<h3 id="basic-elements"><a class="doc-anchor" href="#basic-elements">§</a>Basic elements</h3>
<p>Those are used to recognize the lowest level elements of your grammar, like, “here is a dot”, or “here is an big endian integer”.</p>
<div><table><thead><tr><th>combinator</th><th>usage</th><th>input</th><th>new input</th><th>output</th><th>comment</th></tr></thead><tbody>
<tr><td><a href="../token/fn.one_of.html" title="fn winnow::token::one_of"><code>one_of</code></a></td><td><code>one_of(['a', 'b', 'c'])</code></td><td><code>&quot;abc&quot;</code></td><td><code>&quot;bc&quot;</code></td><td><code>Ok('a')</code></td><td>Matches one of the provided <a href="../stream/trait.ContainsToken.html" title="trait winnow::stream::ContainsToken">set of tokens</a> (works with non ASCII characters too)</td></tr>
<tr><td><a href="../token/fn.none_of.html" title="fn winnow::token::none_of"><code>none_of</code></a></td><td><code>none_of(['a', 'b', 'c'])</code></td><td><code>&quot;xyab&quot;</code></td><td><code>&quot;yab&quot;</code></td><td><code>Ok('x')</code></td><td>Matches anything but one of the provided <a href="../stream/trait.ContainsToken.html" title="trait winnow::stream::ContainsToken">set of tokens</a></td></tr>
<tr><td><a href="../token/fn.literal.html" title="fn winnow::token::literal"><code>literal</code></a></td><td><code>&quot;hello&quot;</code></td><td><code>&quot;hello world&quot;</code></td><td><code>&quot; world&quot;</code></td><td><code>Ok(&quot;hello&quot;)</code></td><td>Recognizes a specific suite of characters or bytes (see also <a href="../ascii/struct.Caseless.html" title="struct winnow::ascii::Caseless"><code>Caseless</code></a>)</td></tr>
<tr><td><a href="../token/fn.take.html" title="fn winnow::token::take"><code>take</code></a></td><td><code>take(4)</code></td><td><code>&quot;hello&quot;</code></td><td><code>&quot;o&quot;</code></td><td><code>Ok(&quot;hell&quot;)</code></td><td>Takes a specific number of bytes or characters</td></tr>
<tr><td><a href="../token/fn.take_while.html" title="fn winnow::token::take_while"><code>take_while</code></a></td><td><code>take_while(0.., is_alphabetic)</code></td><td><code>&quot;abc123&quot;</code></td><td><code>&quot;123&quot;</code></td><td><code>Ok(&quot;abc&quot;)</code></td><td>Returns the longest slice of bytes or characters for which the provided <a href="../stream/trait.ContainsToken.html" title="trait winnow::stream::ContainsToken">set of tokens</a> matches.</td></tr>
<tr><td><a href="../token/fn.take_till.html" title="fn winnow::token::take_till"><code>take_till</code></a></td><td><code>take_till(0.., is_alphabetic)</code></td><td><code>&quot;123abc&quot;</code></td><td><code>&quot;abc&quot;</code></td><td><code>Ok(&quot;123&quot;)</code></td><td>Returns a slice of bytes or characters until the provided <a href="../stream/trait.ContainsToken.html" title="trait winnow::stream::ContainsToken">set of tokens</a> matches. This is the reverse behaviour from <code>take_while</code>: <code>take_till(f)</code> is equivalent to <code>take_while(0.., \|c\| !f(c))</code></td></tr>
<tr><td><a href="../token/fn.take_until.html" title="fn winnow::token::take_until"><code>take_until</code></a></td><td><code>take_until(0.., &quot;world&quot;)</code></td><td><code>&quot;Hello world&quot;</code></td><td><code>&quot;world&quot;</code></td><td><code>Ok(&quot;Hello &quot;)</code></td><td>Returns a slice of bytes or characters until the provided <a href="../token/fn.literal.html" title="fn winnow::token::literal">literal</a> is found.</td></tr>
</tbody></table>
</div><h3 id="choice-combinators"><a class="doc-anchor" href="#choice-combinators">§</a>Choice combinators</h3><div><table><thead><tr><th>combinator</th><th>usage</th><th>input</th><th>new input</th><th>output</th><th>comment</th></tr></thead><tbody>
<tr><td><a href="fn.alt.html" title="fn winnow::combinator::alt"><code>alt</code></a></td><td><code>alt((&quot;ab&quot;, &quot;cd&quot;))</code></td><td><code>&quot;cdef&quot;</code></td><td><code>&quot;ef&quot;</code></td><td><code>Ok(&quot;cd&quot;)</code></td><td>Try a list of parsers and return the result of the first successful one</td></tr>
<tr><td><a href="macro.dispatch.html" title="macro winnow::combinator::dispatch"><code>dispatch</code></a></td><td>-</td><td>-</td><td>-</td><td>-</td><td><code>match</code> for parsers</td></tr>
<tr><td><a href="fn.permutation.html" title="fn winnow::combinator::permutation"><code>permutation</code></a></td><td><code>permutation((&quot;ab&quot;, &quot;cd&quot;, &quot;12&quot;))</code></td><td><code>&quot;cd12abc&quot;</code></td><td><code>&quot;c&quot;</code></td><td><code>Ok((&quot;ab&quot;, &quot;cd&quot;, &quot;12&quot;))</code></td><td>Succeeds when all its child parser have succeeded, whatever the order</td></tr>
</tbody></table>
</div><h3 id="sequence-combinators"><a class="doc-anchor" href="#sequence-combinators">§</a>Sequence combinators</h3><div><table><thead><tr><th>combinator</th><th>usage</th><th>input</th><th>new input</th><th>output</th><th>comment</th></tr></thead><tbody>
<tr><td><a href="../trait.Parser.html" title="trait winnow::Parser"><code>(...)</code> (tuples)</a></td><td><code>(&quot;ab&quot;, &quot;XY&quot;, take(1))</code></td><td><code>&quot;abXYZ!&quot;</code></td><td><code>&quot;!&quot;</code></td><td><code>Ok((&quot;ab&quot;, &quot;XY&quot;, &quot;Z&quot;))</code></td><td>Chains parsers and assemble the sub results in a tuple. You can use as many child parsers as you can put elements in a tuple</td></tr>
<tr><td><a href="macro.seq.html" title="macro winnow::combinator::seq"><code>seq!</code></a></td><td><code>seq!(_: '(', take(2), _: ')')</code></td><td><code>&quot;(ab)cd&quot;</code></td><td><code>&quot;cd&quot;</code></td><td><code>Ok(&quot;ab&quot;)</code></td><td></td></tr>
<tr><td><a href="fn.delimited.html" title="fn winnow::combinator::delimited"><code>delimited</code></a></td><td><code>delimited('(', take(2), ')')</code></td><td><code>&quot;(ab)cd&quot;</code></td><td><code>&quot;cd&quot;</code></td><td><code>Ok(&quot;ab&quot;)</code></td><td></td></tr>
<tr><td><a href="fn.preceded.html" title="fn winnow::combinator::preceded"><code>preceded</code></a></td><td><code>preceded(&quot;ab&quot;, &quot;XY&quot;)</code></td><td><code>&quot;abXYZ&quot;</code></td><td><code>&quot;Z&quot;</code></td><td><code>Ok(&quot;XY&quot;)</code></td><td></td></tr>
<tr><td><a href="fn.terminated.html" title="fn winnow::combinator::terminated"><code>terminated</code></a></td><td><code>terminated(&quot;ab&quot;, &quot;XY&quot;)</code></td><td><code>&quot;abXYZ&quot;</code></td><td><code>&quot;Z&quot;</code></td><td><code>Ok(&quot;ab&quot;)</code></td><td></td></tr>
<tr><td><a href="fn.separated_pair.html" title="fn winnow::combinator::separated_pair"><code>separated_pair</code></a></td><td><code>separated_pair(&quot;hello&quot;, ',', &quot;world&quot;)</code></td><td><code>&quot;hello,world!&quot;</code></td><td><code>&quot;!&quot;</code></td><td><code>Ok((&quot;hello&quot;, &quot;world&quot;))</code></td><td></td></tr>
</tbody></table>
</div><h3 id="applying-a-parser-multiple-times"><a class="doc-anchor" href="#applying-a-parser-multiple-times">§</a>Applying a parser multiple times</h3><div><table><thead><tr><th>combinator</th><th>usage</th><th>input</th><th>new input</th><th>output</th><th>comment</th></tr></thead><tbody>
<tr><td><a href="fn.repeat.html" title="fn winnow::combinator::repeat"><code>repeat</code></a></td><td><code>repeat(1..=3, &quot;ab&quot;)</code></td><td><code>&quot;ababc&quot;</code></td><td><code>&quot;c&quot;</code></td><td><code>Ok(vec![&quot;ab&quot;, &quot;ab&quot;])</code></td><td>Applies the parser between m and n times (n included) and returns the list of results in a Vec</td></tr>
<tr><td><a href="fn.repeat_till.html" title="fn winnow::combinator::repeat_till"><code>repeat_till</code></a></td><td><code>repeat_till(0.., &quot;ab&quot;, &quot;ef&quot;)</code></td><td><code>&quot;ababefg&quot;</code></td><td><code>&quot;g&quot;</code></td><td><code>Ok((vec![&quot;ab&quot;, &quot;ab&quot;], &quot;ef&quot;))</code></td><td>Applies the first parser until the second applies. Returns a tuple containing the list of results from the first in a Vec and the result of the second</td></tr>
<tr><td><a href="fn.separated.html" title="fn winnow::combinator::separated"><code>separated</code></a></td><td><code>separated(1..=3, &quot;ab&quot;, &quot;,&quot;)</code></td><td><code>&quot;ab,ab,ab.&quot;</code></td><td><code>&quot;.&quot;</code></td><td><code>Ok(vec![&quot;ab&quot;, &quot;ab&quot;, &quot;ab&quot;])</code></td><td>Applies the parser and separator between m and n times (n included) and returns the list of results in a Vec</td></tr>
<tr><td><a href="struct.Repeat.html#method.fold" title="method winnow::combinator::Repeat::fold"><code>Repeat::fold</code></a></td><td>`repeat(1..=2, be_u8).fold(</td><td></td><td>0,</td><td>acc, item</td><td>acc + item)`</td></tr>
</tbody></table>
</div><h3 id="partial-related"><a class="doc-anchor" href="#partial-related">§</a>Partial related</h3>
<ul>
<li><a href="fn.eof.html" title="fn winnow::combinator::eof"><code>eof</code></a>: Returns its input if it is at the end of input data</li>
<li><a href="../trait.Parser.html#method.complete_err" title="method winnow::Parser::complete_err"><code>Parser::complete_err</code></a>: Replaces an <code>Incomplete</code> returned by the child parser with an <code>Backtrack</code></li>
</ul>
<h3 id="modifiers"><a class="doc-anchor" href="#modifiers">§</a>Modifiers</h3>
<ul>
<li><a href="fn.cond.html" title="fn winnow::combinator::cond"><code>cond</code></a>: Conditional combinator. Wraps another parser and calls it if the condition is met</li>
<li><a href="../trait.Parser.html#method.flat_map" title="method winnow::Parser::flat_map"><code>Parser::flat_map</code></a>: method to map a new parser from the output of the first parser, then apply that parser over the rest of the input</li>
<li><a href="../trait.Parser.html#method.value" title="method winnow::Parser::value"><code>Parser::value</code></a>: method to replace the result of a parser</li>
<li><a href="../trait.Parser.html#method.default_value" title="method winnow::Parser::default_value"><code>Parser::default_value</code></a>: method to replace the result of a parser</li>
<li><a href="../trait.Parser.html#method.void" title="method winnow::Parser::void"><code>Parser::void</code></a>: method to discard the result of a parser</li>
<li><a href="../trait.Parser.html#method.map" title="method winnow::Parser::map"><code>Parser::map</code></a>: method to map a function on the result of a parser</li>
<li><a href="../trait.Parser.html#method.and_then" title="method winnow::Parser::and_then"><code>Parser::and_then</code></a>: Applies a second parser over the output of the first one</li>
<li><a href="../trait.Parser.html#method.verify_map" title="method winnow::Parser::verify_map"><code>Parser::verify_map</code></a>: Maps a function returning an <code>Option</code> on the output of a parser</li>
<li><a href="../trait.Parser.html#method.try_map" title="method winnow::Parser::try_map"><code>Parser::try_map</code></a>: Maps a function returning a <code>Result</code> on the output of a parser</li>
<li><a href="../trait.Parser.html#method.parse_to" title="method winnow::Parser::parse_to"><code>Parser::parse_to</code></a>: Apply <a href="https://doc.rust-lang.org/1.78.0/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr"><code>std::str::FromStr</code></a> to the output of the parser</li>
<li><a href="fn.not.html" title="fn winnow::combinator::not"><code>not</code></a>: Returns a result only if the embedded parser returns <code>Backtrack</code> or <code>Incomplete</code>. Does not consume the input</li>
<li><a href="fn.opt.html" title="fn winnow::combinator::opt"><code>opt</code></a>: Make the underlying parser optional</li>
<li><a href="fn.peek.html" title="fn winnow::combinator::peek"><code>peek</code></a>: Returns a result without consuming the input</li>
<li><a href="../trait.Parser.html#method.recognize" title="method winnow::Parser::recognize"><code>Parser::recognize</code></a>: If the child parser was successful, return the consumed input as the produced value</li>
<li><a href="../trait.Parser.html#method.with_recognized" title="method winnow::Parser::with_recognized"><code>Parser::with_recognized</code></a>: If the child parser was successful, return a tuple of the consumed input and the produced output.</li>
<li><a href="../trait.Parser.html#method.span" title="method winnow::Parser::span"><code>Parser::span</code></a>: If the child parser was successful, return the location of the consumed input as the produced value</li>
<li><a href="../trait.Parser.html#method.with_span" title="method winnow::Parser::with_span"><code>Parser::with_span</code></a>: If the child parser was successful, return a tuple of the location of the consumed input and the produced output.</li>
<li><a href="../trait.Parser.html#method.verify" title="method winnow::Parser::verify"><code>Parser::verify</code></a>: Returns the result of the child parser if it satisfies a verification function</li>
</ul>
<h3 id="error-management-and-debugging"><a class="doc-anchor" href="#error-management-and-debugging">§</a>Error management and debugging</h3>
<ul>
<li><a href="fn.cut_err.html" title="fn winnow::combinator::cut_err"><code>cut_err</code></a>: Commit the parse result, disallowing alternative parsers from being attempted</li>
<li><a href="fn.backtrack_err.html" title="fn winnow::combinator::backtrack_err"><code>backtrack_err</code></a>: Attempts a parse, allowing alternative parsers to be attempted despite
use of <code>cut_err</code></li>
<li><a href="../trait.Parser.html#method.context" title="method winnow::Parser::context"><code>Parser::context</code></a>: Add context to the error if the parser fails</li>
<li><a href="fn.trace.html" title="fn winnow::combinator::trace"><code>trace</code></a>: Print the parse state with the <code>debug</code> feature flag</li>
<li><a href="fn.todo.html" title="fn winnow::combinator::todo"><code>todo()</code></a>: Placeholder parser</li>
</ul>
<h3 id="remaining-combinators"><a class="doc-anchor" href="#remaining-combinators">§</a>Remaining combinators</h3>
<ul>
<li><a href="fn.empty.html" title="fn winnow::combinator::empty"><code>empty</code></a>: Returns a value without consuming any input, always succeeds</li>
<li><a href="fn.fail.html" title="fn winnow::combinator::fail"><code>fail</code></a>: Inversion of <a href="fn.empty.html" title="fn winnow::combinator::empty"><code>empty</code></a>. Always fails.</li>
<li><a href="../trait.Parser.html#method.by_ref" title="method winnow::Parser::by_ref"><code>Parser::by_ref</code></a>: Allow moving <code>&amp;mut impl Parser</code> into other parsers</li>
</ul>
<h3 id="text-parsing"><a class="doc-anchor" href="#text-parsing">§</a>Text parsing</h3>
<ul>
<li>
<p><a href="../token/fn.any.html" title="fn winnow::token::any"><code>any</code></a>: Matches one token</p>
</li>
<li>
<p><a href="../ascii/fn.tab.html" title="fn winnow::ascii::tab"><code>tab</code></a>: Matches a tab character <code>\t</code></p>
</li>
<li>
<p><a href="../ascii/fn.crlf.html" title="fn winnow::ascii::crlf"><code>crlf</code></a>: Recognizes the string <code>\r\n</code></p>
</li>
<li>
<p><a href="../ascii/fn.line_ending.html" title="fn winnow::ascii::line_ending"><code>line_ending</code></a>: Recognizes an end of line (both <code>\n</code> and <code>\r\n</code>)</p>
</li>
<li>
<p><a href="../ascii/fn.newline.html" title="fn winnow::ascii::newline"><code>newline</code></a>: Matches a newline character <code>\n</code></p>
</li>
<li>
<p><a href="../ascii/fn.till_line_ending.html" title="fn winnow::ascii::till_line_ending"><code>till_line_ending</code></a>: Recognizes a string of any char except <code>\r</code> or <code>\n</code></p>
</li>
<li>
<p><a href="fn.rest.html" title="fn winnow::combinator::rest"><code>rest</code></a>: Return the remaining input</p>
</li>
<li>
<p><a href="../ascii/fn.alpha0.html" title="fn winnow::ascii::alpha0"><code>alpha0</code></a>: Recognizes zero or more lowercase and uppercase alphabetic characters: <code>[a-zA-Z]</code>. <a href="../ascii/fn.alpha1.html" title="fn winnow::ascii::alpha1"><code>alpha1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.alphanumeric0.html" title="fn winnow::ascii::alphanumeric0"><code>alphanumeric0</code></a>: Recognizes zero or more numerical and alphabetic characters: <code>[0-9a-zA-Z]</code>. <a href="../ascii/fn.alphanumeric1.html" title="fn winnow::ascii::alphanumeric1"><code>alphanumeric1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.space0.html" title="fn winnow::ascii::space0"><code>space0</code></a>: Recognizes zero or more spaces and tabs. <a href="../ascii/fn.space1.html" title="fn winnow::ascii::space1"><code>space1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.multispace0.html" title="fn winnow::ascii::multispace0"><code>multispace0</code></a>: Recognizes zero or more spaces, tabs, carriage returns and line feeds. <a href="../ascii/fn.multispace1.html" title="fn winnow::ascii::multispace1"><code>multispace1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.digit0.html" title="fn winnow::ascii::digit0"><code>digit0</code></a>: Recognizes zero or more numerical characters: <code>[0-9]</code>. <a href="../ascii/fn.digit1.html" title="fn winnow::ascii::digit1"><code>digit1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.hex_digit0.html" title="fn winnow::ascii::hex_digit0"><code>hex_digit0</code></a>: Recognizes zero or more hexadecimal numerical characters: <code>[0-9A-Fa-f]</code>. <a href="../ascii/fn.hex_digit1.html" title="fn winnow::ascii::hex_digit1"><code>hex_digit1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.oct_digit0.html" title="fn winnow::ascii::oct_digit0"><code>oct_digit0</code></a>: Recognizes zero or more octal characters: <code>[0-7]</code>. <a href="../ascii/fn.oct_digit1.html" title="fn winnow::ascii::oct_digit1"><code>oct_digit1</code></a> does the same but returns at least one character</p>
</li>
<li>
<p><a href="../ascii/fn.float.html" title="fn winnow::ascii::float"><code>float</code></a>: Parse a floating point number in a byte string</p>
</li>
<li>
<p><a href="../ascii/fn.dec_int.html" title="fn winnow::ascii::dec_int"><code>dec_int</code></a>: Decode a variable-width, decimal signed integer</p>
</li>
<li>
<p><a href="../ascii/fn.dec_uint.html" title="fn winnow::ascii::dec_uint"><code>dec_uint</code></a>: Decode a variable-width, decimal unsigned integer</p>
</li>
<li>
<p><a href="../ascii/fn.hex_uint.html" title="fn winnow::ascii::hex_uint"><code>hex_uint</code></a>: Decode a variable-width, hexadecimal integer</p>
</li>
<li>
<p><a href="../ascii/fn.take_escaped.html" title="fn winnow::ascii::take_escaped"><code>take_escaped</code></a>: Recognize the input slice with escaped characters</p>
</li>
<li>
<p><a href="../ascii/fn.escaped_transform.html" title="fn winnow::ascii::escaped_transform"><code>escaped_transform</code></a>: Parse escaped characters, unescaping them</p>
</li>
</ul>
<h4 id="character-test-functions"><a class="doc-anchor" href="#character-test-functions">§</a>Character test functions</h4>
<p>Use these functions with a combinator like <code>take_while</code>:</p>
<ul>
<li><a href="../stream/trait.AsChar.html#tymethod.is_alpha" title="method winnow::stream::AsChar::is_alpha"><code>AsChar::is_alpha</code></a>: Tests if byte is ASCII alphabetic: <code>[A-Za-z]</code></li>
<li><a href="../stream/trait.AsChar.html#tymethod.is_alphanum" title="method winnow::stream::AsChar::is_alphanum"><code>AsChar::is_alphanum</code></a>: Tests if byte is ASCII alphanumeric: <code>[A-Za-z0-9]</code></li>
<li><a href="../stream/trait.AsChar.html#tymethod.is_dec_digit" title="method winnow::stream::AsChar::is_dec_digit"><code>AsChar::is_dec_digit</code></a>: Tests if byte is ASCII digit: <code>[0-9]</code></li>
<li><a href="../stream/trait.AsChar.html#tymethod.is_hex_digit" title="method winnow::stream::AsChar::is_hex_digit"><code>AsChar::is_hex_digit</code></a>: Tests if byte is ASCII hex digit: <code>[0-9A-Fa-f]</code></li>
<li><a href="../stream/trait.AsChar.html#tymethod.is_oct_digit" title="method winnow::stream::AsChar::is_oct_digit"><code>AsChar::is_oct_digit</code></a>: Tests if byte is ASCII octal digit: <code>[0-7]</code></li>
<li><a href="../stream/trait.AsChar.html#tymethod.is_space" title="method winnow::stream::AsChar::is_space"><code>AsChar::is_space</code></a>: Tests if byte is ASCII space or tab: <code>[ \t]</code></li>
<li><a href="../stream/trait.AsChar.html#tymethod.is_newline" title="method winnow::stream::AsChar::is_newline"><code>AsChar::is_newline</code></a>: Tests if byte is ASCII newline: <code>[\n]</code></li>
</ul>
<h3 id="binary-format-parsing"><a class="doc-anchor" href="#binary-format-parsing">§</a>Binary format parsing</h3>
<ul>
<li><a href="../binary/fn.length_repeat.html" title="fn winnow::binary::length_repeat"><code>length_repeat</code></a> Gets a number from the first parser, then applies the second parser that many times</li>
<li><a href="../binary/fn.length_take.html" title="fn winnow::binary::length_take"><code>length_take</code></a>: Gets a number from the first parser, then takes a subslice of the input of that size, and returns that subslice</li>
<li><a href="../binary/fn.length_and_then.html" title="fn winnow::binary::length_and_then"><code>length_and_then</code></a>: Gets a number from the first parser, takes a subslice of the input of that size, then applies the second parser on that subslice. If the second parser returns <code>Incomplete</code>, <code>length_value</code> will return an error</li>
</ul>
<h4 id="integers"><a class="doc-anchor" href="#integers">§</a>Integers</h4>
<p>Parsing integers from binary formats can be done in two ways: With parser functions, or combinators with configurable endianness.</p>
<ul>
<li><strong>configurable endianness:</strong> <a href="../binary/fn.i16.html" title="fn winnow::binary::i16"><code>i16</code></a>, <a href="../binary/fn.i32.html" title="fn winnow::binary::i32"><code>i32</code></a>,
<a href="../binary/fn.i64.html" title="fn winnow::binary::i64"><code>i64</code></a>, <a href="../binary/fn.u16.html" title="fn winnow::binary::u16"><code>u16</code></a>, <a href="../binary/fn.u32.html" title="fn winnow::binary::u32"><code>u32</code></a>,
<a href="../binary/fn.u64.html" title="fn winnow::binary::u64"><code>u64</code></a> are combinators that take as argument a
<a href="../binary/enum.Endianness.html" title="enum winnow::binary::Endianness"><code>winnow::binary::Endianness</code></a>, like this: <code>i16(endianness)</code>. If the
parameter is <code>winnow::binary::Endianness::Big</code>, parse a big endian <code>i16</code> integer, otherwise a
little endian <code>i16</code> integer.</li>
<li><strong>fixed endianness</strong>: The functions are prefixed by <code>be_</code> for big endian numbers, and by <code>le_</code> for little endian numbers, and the suffix is the type they parse to. As an example, <code>be_u32</code> parses a big endian unsigned integer stored in 32 bits.
<ul>
<li><a href="../binary/fn.be_f32.html" title="fn winnow::binary::be_f32"><code>be_f32</code></a>, <a href="../binary/fn.be_f64.html" title="fn winnow::binary::be_f64"><code>be_f64</code></a>: Big endian floating point numbers</li>
<li><a href="../binary/fn.le_f32.html" title="fn winnow::binary::le_f32"><code>le_f32</code></a>, <a href="../binary/fn.le_f64.html" title="fn winnow::binary::le_f64"><code>le_f64</code></a>: Little endian floating point numbers</li>
<li><a href="../binary/fn.be_i8.html" title="fn winnow::binary::be_i8"><code>be_i8</code></a>, <a href="../binary/fn.be_i16.html" title="fn winnow::binary::be_i16"><code>be_i16</code></a>, <a href="../binary/fn.be_i24.html" title="fn winnow::binary::be_i24"><code>be_i24</code></a>, <a href="../binary/fn.be_i32.html" title="fn winnow::binary::be_i32"><code>be_i32</code></a>, <a href="../binary/fn.be_i64.html" title="fn winnow::binary::be_i64"><code>be_i64</code></a>, <a href="../binary/fn.be_i128.html" title="fn winnow::binary::be_i128"><code>be_i128</code></a>: Big endian signed integers</li>
<li><a href="../binary/fn.be_u8.html" title="fn winnow::binary::be_u8"><code>be_u8</code></a>, <a href="../binary/fn.be_u16.html" title="fn winnow::binary::be_u16"><code>be_u16</code></a>, <a href="../binary/fn.be_u24.html" title="fn winnow::binary::be_u24"><code>be_u24</code></a>, <a href="../binary/fn.be_u32.html" title="fn winnow::binary::be_u32"><code>be_u32</code></a>, <a href="../binary/fn.be_u64.html" title="fn winnow::binary::be_u64"><code>be_u64</code></a>, <a href="../binary/fn.be_u128.html" title="fn winnow::binary::be_u128"><code>be_u128</code></a>: Big endian unsigned integers</li>
<li><a href="../binary/fn.le_i8.html" title="fn winnow::binary::le_i8"><code>le_i8</code></a>, <a href="../binary/fn.le_i16.html" title="fn winnow::binary::le_i16"><code>le_i16</code></a>, <a href="../binary/fn.le_i24.html" title="fn winnow::binary::le_i24"><code>le_i24</code></a>, <a href="../binary/fn.le_i32.html" title="fn winnow::binary::le_i32"><code>le_i32</code></a>, <a href="../binary/fn.le_i64.html" title="fn winnow::binary::le_i64"><code>le_i64</code></a>, <a href="../binary/fn.le_i128.html" title="fn winnow::binary::le_i128"><code>le_i128</code></a>: Little endian signed integers</li>
<li><a href="../binary/fn.le_u8.html" title="fn winnow::binary::le_u8"><code>le_u8</code></a>, <a href="../binary/fn.le_u16.html" title="fn winnow::binary::le_u16"><code>le_u16</code></a>, <a href="../binary/fn.le_u24.html" title="fn winnow::binary::le_u24"><code>le_u24</code></a>, <a href="../binary/fn.le_u32.html" title="fn winnow::binary::le_u32"><code>le_u32</code></a>, <a href="../binary/fn.le_u64.html" title="fn winnow::binary::le_u64"><code>le_u64</code></a>, <a href="../binary/fn.le_u128.html" title="fn winnow::binary::le_u128"><code>le_u128</code></a>: Little endian unsigned integers</li>
</ul>
</li>
</ul>
<h4 id="bit-stream-parsing"><a class="doc-anchor" href="#bit-stream-parsing">§</a>Bit stream parsing</h4>
<ul>
<li><a href="../binary/bits/fn.bits.html" title="fn winnow::binary::bits::bits"><code>bits</code></a>: Transforms the current input type (byte slice <code>&amp;[u8]</code>) to a bit stream on which bit specific parsers and more general combinators can be applied</li>
<li><a href="../binary/bits/fn.bytes.html" title="fn winnow::binary::bits::bytes"><code>bytes</code></a>: Transforms its bits stream input back into a byte slice for the underlying parser</li>
<li><a href="../binary/bits/fn.take.html" title="fn winnow::binary::bits::take"><code>take</code></a>: Take a set number of bits</li>
<li><a href="../binary/bits/fn.pattern.html" title="fn winnow::binary::bits::pattern"><code>pattern</code></a>: Check if a set number of bits matches a pattern</li>
<li><a href="../binary/bits/fn.bool.html" title="fn winnow::binary::bits::bool"><code>bool</code></a>: Match any one bit</li>
</ul>
</div></details><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.dispatch.html" title="macro winnow::combinator::dispatch">dispatch</a></div><div class="desc docblock-short"><code>match</code> for parsers</div></li><li><div class="item-name"><a class="macro" href="macro.seq.html" title="macro winnow::combinator::seq">seq</a></div><div class="desc docblock-short">Initialize a struct or tuple out of a sequences of parsers</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.AndThen.html" title="struct winnow::combinator::AndThen">AndThen</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.and_then" title="method winnow::Parser::and_then"><code>Parser::and_then</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.ByRef.html" title="struct winnow::combinator::ByRef">ByRef</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.by_ref" title="method winnow::Parser::by_ref"><code>Parser::by_ref</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.CompleteErr.html" title="struct winnow::combinator::CompleteErr">CompleteErr</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.complete_err" title="method winnow::Parser::complete_err"><code>Parser::complete_err</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Context.html" title="struct winnow::combinator::Context">Context</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.context" title="method winnow::Parser::context"><code>Parser::context</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.DefaultValue.html" title="struct winnow::combinator::DefaultValue">DefaultValue</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.default_value" title="method winnow::Parser::default_value"><code>Parser::default_value</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.ErrInto.html" title="struct winnow::combinator::ErrInto">ErrInto</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.err_into" title="method winnow::Parser::err_into"><code>Parser::err_into</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.FlatMap.html" title="struct winnow::combinator::FlatMap">FlatMap</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.flat_map" title="method winnow::Parser::flat_map"><code>Parser::flat_map</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Map.html" title="struct winnow::combinator::Map">Map</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.map" title="method winnow::Parser::map"><code>Parser::map</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.OutputInto.html" title="struct winnow::combinator::OutputInto">OutputInto</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.output_into" title="method winnow::Parser::output_into"><code>Parser::output_into</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.ParseTo.html" title="struct winnow::combinator::ParseTo">ParseTo</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.parse_to" title="method winnow::Parser::parse_to"><code>Parser::parse_to</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.ParserIterator.html" title="struct winnow::combinator::ParserIterator">ParserIterator</a></div><div class="desc docblock-short">Main structure associated to <a href="fn.iterator.html" title="fn winnow::combinator::iterator"><code>iterator</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Recognize.html" title="struct winnow::combinator::Recognize">Recognize</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.recognize" title="method winnow::Parser::recognize"><code>Parser::recognize</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Repeat.html" title="struct winnow::combinator::Repeat">Repeat</a></div><div class="desc docblock-short">Implementation of <a href="fn.repeat.html" title="fn winnow::combinator::repeat"><code>repeat</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Span.html" title="struct winnow::combinator::Span">Span</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.span" title="method winnow::Parser::span"><code>Parser::span</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.TryMap.html" title="struct winnow::combinator::TryMap">TryMap</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.try_map" title="method winnow::Parser::try_map"><code>Parser::try_map</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Value.html" title="struct winnow::combinator::Value">Value</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.value" title="method winnow::Parser::value"><code>Parser::value</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Verify.html" title="struct winnow::combinator::Verify">Verify</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.verify" title="method winnow::Parser::verify"><code>Parser::verify</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.VerifyMap.html" title="struct winnow::combinator::VerifyMap">VerifyMap</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.verify_map" title="method winnow::Parser::verify_map"><code>Parser::verify_map</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.Void.html" title="struct winnow::combinator::Void">Void</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.void" title="method winnow::Parser::void"><code>Parser::void</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.WithRecognized.html" title="struct winnow::combinator::WithRecognized">WithRecognized</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.with_recognized" title="method winnow::Parser::with_recognized"><code>Parser::with_recognized</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.WithSpan.html" title="struct winnow::combinator::WithSpan">WithSpan</a></div><div class="desc docblock-short">Implementation of <a href="../trait.Parser.html#method.with_span" title="method winnow::Parser::with_span"><code>Parser::with_span</code></a></div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Alt.html" title="trait winnow::combinator::Alt">Alt</a></div><div class="desc docblock-short">Helper trait for the <a href="fn.alt.html" title="fn winnow::combinator::alt"><code>alt()</code></a> combinator.</div></li><li><div class="item-name"><a class="trait" href="trait.Permutation.html" title="trait winnow::combinator::Permutation">Permutation</a></div><div class="desc docblock-short">Helper trait for the <a href="fn.permutation.html" title="fn winnow::combinator::permutation"><code>permutation()</code></a> combinator.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.alt.html" title="fn winnow::combinator::alt">alt</a></div><div class="desc docblock-short">Pick the first successful parser</div></li><li><div class="item-name"><a class="fn" href="fn.backtrack_err.html" title="fn winnow::combinator::backtrack_err">backtrack_err</a></div><div class="desc docblock-short">Transforms an <a href="../error/enum.ErrMode.html#variant.Cut" title="variant winnow::error::ErrMode::Cut"><code>ErrMode::Cut</code></a> (unrecoverable) to <a href="../error/enum.ErrMode.html#variant.Backtrack" title="variant winnow::error::ErrMode::Backtrack"><code>ErrMode::Backtrack</code></a> (recoverable)</div></li><li><div class="item-name"><a class="fn" href="fn.cond.html" title="fn winnow::combinator::cond">cond</a></div><div class="desc docblock-short">Calls the parser if the condition is met.</div></li><li><div class="item-name"><a class="fn" href="fn.cut_err.html" title="fn winnow::combinator::cut_err">cut_err</a></div><div class="desc docblock-short">Transforms an <a href="../error/enum.ErrMode.html#variant.Backtrack" title="variant winnow::error::ErrMode::Backtrack"><code>ErrMode::Backtrack</code></a> (recoverable) to <a href="../error/enum.ErrMode.html#variant.Cut" title="variant winnow::error::ErrMode::Cut"><code>ErrMode::Cut</code></a> (unrecoverable)</div></li><li><div class="item-name"><a class="fn" href="fn.delimited.html" title="fn winnow::combinator::delimited">delimited</a></div><div class="desc docblock-short">Sequence three parsers, only returning the output of the second.</div></li><li><div class="item-name"><a class="fn" href="fn.empty.html" title="fn winnow::combinator::empty">empty</a></div><div class="desc docblock-short">Succeed, consuming no input</div></li><li><div class="item-name"><a class="fn" href="fn.eof.html" title="fn winnow::combinator::eof">eof</a></div><div class="desc docblock-short">Match the end of the <a href="../stream/trait.Stream.html" title="trait winnow::stream::Stream"><code>Stream</code></a></div></li><li><div class="item-name"><a class="fn" href="fn.fail.html" title="fn winnow::combinator::fail">fail</a></div><div class="desc docblock-short">A parser which always fails.</div></li><li><div class="item-name"><a class="fn" href="fn.fill.html" title="fn winnow::combinator::fill">fill</a></div><div class="desc docblock-short">Repeats the embedded parser, filling the given slice with results.</div></li><li><div class="item-name"><a class="fn" href="fn.iterator.html" title="fn winnow::combinator::iterator">iterator</a></div><div class="desc docblock-short">Repeats the embedded parser, lazily returning the results</div></li><li><div class="item-name"><a class="fn" href="fn.not.html" title="fn winnow::combinator::not">not</a></div><div class="desc docblock-short">Succeeds if the child parser returns an error.</div></li><li><div class="item-name"><a class="fn" href="fn.opt.html" title="fn winnow::combinator::opt">opt</a></div><div class="desc docblock-short">Apply a <a href="../trait.Parser.html" title="trait winnow::Parser"><code>Parser</code></a>, producing <code>None</code> on <a href="../error/enum.ErrMode.html#variant.Backtrack" title="variant winnow::error::ErrMode::Backtrack"><code>ErrMode::Backtrack</code></a>.</div></li><li><div class="item-name"><a class="fn" href="fn.peek.html" title="fn winnow::combinator::peek">peek</a></div><div class="desc docblock-short">Tries to apply its parser without consuming the input.</div></li><li><div class="item-name"><a class="fn" href="fn.permutation.html" title="fn winnow::combinator::permutation">permutation</a></div><div class="desc docblock-short">Applies a list of parsers in any order.</div></li><li><div class="item-name"><a class="fn" href="fn.preceded.html" title="fn winnow::combinator::preceded">preceded</a></div><div class="desc docblock-short">Sequence two parsers, only returning the output from the second.</div></li><li><div class="item-name"><a class="fn" href="fn.repeat.html" title="fn winnow::combinator::repeat">repeat</a></div><div class="desc docblock-short"><a href="../stream/trait.Accumulate.html" title="trait winnow::stream::Accumulate"><code>Accumulate</code></a> the output of a parser into a container, like <code>Vec</code></div></li><li><div class="item-name"><a class="fn" href="fn.repeat_till.html" title="fn winnow::combinator::repeat_till">repeat_till</a></div><div class="desc docblock-short"><a href="../stream/trait.Accumulate.html" title="trait winnow::stream::Accumulate"><code>Accumulate</code></a> the output of parser <code>f</code> into a container, like <code>Vec</code>, until the parser <code>g</code>
produces a result.</div></li><li><div class="item-name"><a class="fn" href="fn.rest.html" title="fn winnow::combinator::rest">rest</a></div><div class="desc docblock-short">Return the remaining input.</div></li><li><div class="item-name"><a class="fn" href="fn.rest_len.html" title="fn winnow::combinator::rest_len">rest_len</a></div><div class="desc docblock-short">Return the length of the remaining input.</div></li><li><div class="item-name"><a class="fn" href="fn.separated.html" title="fn winnow::combinator::separated">separated</a></div><div class="desc docblock-short"><a href="../stream/trait.Accumulate.html" title="trait winnow::stream::Accumulate"><code>Accumulate</code></a> the output of a parser, interleaved with <code>sep</code></div></li><li><div class="item-name"><a class="fn" href="fn.separated_foldl1.html" title="fn winnow::combinator::separated_foldl1">separated_foldl1</a></div><div class="desc docblock-short">Alternates between two parsers, merging the results (left associative)</div></li><li><div class="item-name"><a class="fn" href="fn.separated_foldr1.html" title="fn winnow::combinator::separated_foldr1">separated_foldr1</a></div><div class="desc docblock-short">Alternates between two parsers, merging the results (right associative)</div></li><li><div class="item-name"><a class="fn" href="fn.separated_pair.html" title="fn winnow::combinator::separated_pair">separated_pair</a></div><div class="desc docblock-short">Sequence three parsers, only returning the values of the first and third.</div></li><li><div class="item-name"><a class="fn" href="fn.terminated.html" title="fn winnow::combinator::terminated">terminated</a></div><div class="desc docblock-short">Sequence two parsers, only returning the output of the first.</div></li><li><div class="item-name"><a class="fn" href="fn.todo.html" title="fn winnow::combinator::todo">todo</a></div><div class="desc docblock-short">A placeholder for a not-yet-implemented <a href="../trait.Parser.html" title="trait winnow::Parser"><code>Parser</code></a></div></li><li><div class="item-name"><a class="fn" href="fn.trace.html" title="fn winnow::combinator::trace">trace</a></div><div class="desc docblock-short">Trace the execution of the parser</div></li></ul></section></div></main></body></html>