Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
<!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="Extensions to the parsing API with niche applicability."><title>syn::parse::discouraged - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Module discouraged</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module discouraged</a></h2><h3><a href="#traits">Module Items</a></h3><ul class="block"><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In syn::<wbr>parse</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">syn</a>::<wbr><a href="../index.html">parse</a></div><h1>Module <span>discouraged</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/syn/discouraged.rs.html#1-225">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extensions to the parsing API with niche applicability.</p>
</div></details><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.AnyDelimiter.html" title="trait syn::parse::discouraged::AnyDelimiter">AnyDelimiter</a></dt><dd>Extensions to the <code>ParseStream</code> API to support manipulating invisible
delimiters the same as if they were visible.</dd><dt><a class="trait" href="trait.Speculative.html" title="trait syn::parse::discouraged::Speculative">Speculative</a></dt><dd>Extensions to the <code>ParseStream</code> API to support speculative parsing.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"trait":["AnyDelimiter","Speculative"]};

View File

@@ -0,0 +1,10 @@
<!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="Extensions to the `ParseStream` API to support manipulating invisible delimiters the same as if they were visible."><title>AnyDelimiter in syn::parse::discouraged - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">AnyDelimiter</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">AnyDelimiter</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.parse_any_delimiter" title="parse_any_delimiter">parse_any_delimiter</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse::<wbr>discouraged</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">syn</a>::<wbr><a href="../index.html">parse</a>::<wbr><a href="index.html">discouraged</a></div><h1>Trait <span class="trait">AnyDelimiter</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/syn/discouraged.rs.html#205-209">Source</a> </span></div><pre class="rust item-decl"><code>pub trait AnyDelimiter {
// Required method
fn <a href="#tymethod.parse_any_delimiter" class="fn">parse_any_delimiter</a>(
&amp;self,
) -&gt; <a class="type" href="../../type.Result.html" title="type syn::Result">Result</a>&lt;(<a class="enum" href="../../../proc_macro2/enum.Delimiter.html" title="enum proc_macro2::Delimiter">Delimiter</a>, <a class="struct" href="../../../proc_macro2/extra/struct.DelimSpan.html" title="struct proc_macro2::extra::DelimSpan">DelimSpan</a>, <a class="struct" href="../struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer">ParseBuffer</a>&lt;'_&gt;)&gt;;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extensions to the <code>ParseStream</code> API to support manipulating invisible
delimiters the same as if they were visible.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.parse_any_delimiter" class="method"><a class="src rightside" href="../../../src/syn/discouraged.rs.html#208">Source</a><h4 class="code-header">fn <a href="#tymethod.parse_any_delimiter" class="fn">parse_any_delimiter</a>(&amp;self) -&gt; <a class="type" href="../../type.Result.html" title="type syn::Result">Result</a>&lt;(<a class="enum" href="../../../proc_macro2/enum.Delimiter.html" title="enum proc_macro2::Delimiter">Delimiter</a>, <a class="struct" href="../../../proc_macro2/extra/struct.DelimSpan.html" title="struct proc_macro2::extra::DelimSpan">DelimSpan</a>, <a class="struct" href="../struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer">ParseBuffer</a>&lt;'_&gt;)&gt;</h4></section></summary><div class="docblock"><p>Returns the delimiter, the span of the delimiter token, and the nested
contents for further parsing.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-AnyDelimiter-for-ParseBuffer%3C'a%3E" class="impl"><a class="src rightside" href="../../../src/syn/discouraged.rs.html#211-225">Source</a><a href="#impl-AnyDelimiter-for-ParseBuffer%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="trait.AnyDelimiter.html" title="trait syn::parse::discouraged::AnyDelimiter">AnyDelimiter</a> for <a class="struct" href="../struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer">ParseBuffer</a>&lt;'a&gt;</h3></section></div><script src="../../../trait.impl/syn/parse/discouraged/trait.AnyDelimiter.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,106 @@
<!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="Extensions to the `ParseStream` API to support speculative parsing."><title>Speculative in syn::parse::discouraged - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Speculative</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Speculative</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.advance_to" title="advance_to">advance_to</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse::<wbr>discouraged</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">syn</a>::<wbr><a href="../index.html">parse</a>::<wbr><a href="index.html">discouraged</a></div><h1>Trait <span class="trait">Speculative</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/syn/discouraged.rs.html#13-165">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Speculative {
// Required method
fn <a href="#tymethod.advance_to" class="fn">advance_to</a>(&amp;self, fork: &amp;Self);
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extensions to the <code>ParseStream</code> API to support speculative parsing.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.advance_to" class="method"><a class="src rightside" href="../../../src/syn/discouraged.rs.html#164">Source</a><h4 class="code-header">fn <a href="#tymethod.advance_to" class="fn">advance_to</a>(&amp;self, fork: &amp;Self)</h4></section></summary><div class="docblock"><p>Advance this parse stream to the position of a forked parse stream.</p>
<p>This is the opposite operation to <a href="../struct.ParseBuffer.html#method.fork" title="method syn::parse::ParseBuffer::fork"><code>ParseStream::fork</code></a>. You can fork a
parse stream, perform some speculative parsing, then join the original
stream to the fork to “commit” the parsing from the fork to the main
stream.</p>
<p>If you can avoid doing this, you should, as it limits the ability to
generate useful errors. That said, it is often the only way to parse
syntax of the form <code>A* B*</code> for arbitrary syntax <code>A</code> and <code>B</code>. The problem
is that when the fork fails to parse an <code>A</code>, its impossible to tell
whether that was because of a syntax error and the user meant to provide
an <code>A</code>, or that the <code>A</code>s are finished and its time to start parsing
<code>B</code>s. Use with care.</p>
<p>Also note that if <code>A</code> is a subset of <code>B</code>, <code>A* B*</code> can be parsed by
parsing <code>B*</code> and removing the leading members of <code>A</code> from the
repetition, bypassing the need to involve the downsides associated with
speculative parsing.</p>
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
<p>There has been chatter about the possibility of making the colons in the
turbofish syntax like <code>path::to::&lt;T&gt;</code> no longer required by accepting
<code>path::to&lt;T&gt;</code> in expression position. Specifically, according to <a href="https://github.com/rust-lang/rfcs/pull/2544">RFC
2544</a>, <a href="../../struct.PathSegment.html" title="struct syn::PathSegment"><code>PathSegment</code></a> parsing should always try to consume a following
<code>&lt;</code> token as the start of generic arguments, and reset to the <code>&lt;</code> if
that fails (e.g. the token is acting as a less-than operator).</p>
<p>This is the exact kind of parsing behavior which requires the “fork,
try, commit” behavior that <a href="../struct.ParseBuffer.html#method.fork" title="method syn::parse::ParseBuffer::fork"><code>ParseStream::fork</code></a> discourages. With
<code>advance_to</code>, we can avoid having to parse the speculatively parsed
content a second time.</p>
<p>This change in behavior can be implemented in syn by replacing just the
<code>Parse</code> implementation for <code>PathSegment</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>syn::parse::discouraged::Speculative;
<span class="kw">pub struct </span>PathSegment {
<span class="kw">pub </span>ident: Ident,
<span class="kw">pub </span>arguments: PathArguments,
}
<span class="kw">impl </span>Parse <span class="kw">for </span>PathSegment {
<span class="kw">fn </span>parse(input: ParseStream) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">if </span>input.peek(<span class="macro">Token!</span>[<span class="kw">super</span>])
|| input.peek(<span class="macro">Token!</span>[<span class="self">self</span>])
|| input.peek(<span class="macro">Token!</span>[<span class="self">Self</span>])
|| input.peek(<span class="macro">Token!</span>[<span class="kw">crate</span>])
{
<span class="kw">let </span>ident = input.call(Ident::parse_any)<span class="question-mark">?</span>;
<span class="kw">return </span><span class="prelude-val">Ok</span>(PathSegment::from(ident));
}
<span class="kw">let </span>ident = input.parse()<span class="question-mark">?</span>;
<span class="kw">if </span>input.peek(<span class="macro">Token!</span>[::]) &amp;&amp; input.peek3(<span class="macro">Token!</span>[&lt;]) {
<span class="kw">return </span><span class="prelude-val">Ok</span>(PathSegment {
ident,
arguments: PathArguments::AngleBracketed(input.parse()<span class="question-mark">?</span>),
});
}
<span class="kw">if </span>input.peek(<span class="macro">Token!</span>[&lt;]) &amp;&amp; !input.peek(<span class="macro">Token!</span>[&lt;=]) {
<span class="kw">let </span>fork = input.fork();
<span class="kw">if let </span><span class="prelude-val">Ok</span>(arguments) = fork.parse() {
input.advance_to(<span class="kw-2">&amp;</span>fork);
<span class="kw">return </span><span class="prelude-val">Ok</span>(PathSegment {
ident,
arguments: PathArguments::AngleBracketed(arguments),
});
}
}
<span class="prelude-val">Ok</span>(PathSegment::from(ident))
}
}
</code></pre></div><h5 id="drawbacks"><a class="doc-anchor" href="#drawbacks">§</a>Drawbacks</h5>
<p>The main drawback of this style of speculative parsing is in error
presentation. Even if the lookahead is the “correct” parse, the error
that is shown is that of the “fallback” parse. To use the same example
as the turbofish above, take the following unfinished “turbofish”:</p>
<div class="example-wrap"><pre class="language-text"><code>let _ = f&lt;&amp;&#39;a fn(), for&lt;&#39;a&gt; serde::&gt;();</code></pre></div>
<p>If this is parsed as generic arguments, we can provide the error message</p>
<div class="example-wrap"><pre class="language-text"><code>error: expected identifier
--&gt; src.rs:L:C
|
L | let _ = f&lt;&amp;&#39;a fn(), for&lt;&#39;a&gt; serde::&gt;();
| ^</code></pre></div>
<p>but if parsed using the above speculative parsing, it falls back to
assuming that the <code>&lt;</code> is a less-than when it fails to parse the generic
arguments, and tries to interpret the <code>&amp;'a</code> as the start of a labelled
loop, resulting in the much less helpful error</p>
<div class="example-wrap"><pre class="language-text"><code>error: expected `:`
--&gt; src.rs:L:C
|
L | let _ = f&lt;&amp;&#39;a fn(), for&lt;&#39;a&gt; serde::&gt;();
| ^^</code></pre></div>
<p>This can be mitigated with various heuristics (two examples: show both
forks parse errors, or show the one that consumed more tokens), but
when you can control the grammar, sticking to something that can be
parsed LL(3) and without the LL(*) speculative parsing this makes
possible, displaying reasonable errors becomes much more simple.</p>
<h5 id="performance"><a class="doc-anchor" href="#performance">§</a>Performance</h5>
<p>This method performs a cheap fixed amount of work that does not depend
on how far apart the two streams are positioned.</p>
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
<p>The forked stream in the argument of <code>advance_to</code> must have been
obtained by forking <code>self</code>. Attempting to advance to any other stream
will cause a panic.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Speculative-for-ParseBuffer%3C'a%3E" class="impl"><a class="src rightside" href="../../../src/syn/discouraged.rs.html#167-201">Source</a><a href="#impl-Speculative-for-ParseBuffer%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="trait.Speculative.html" title="trait syn::parse::discouraged::Speculative">Speculative</a> for <a class="struct" href="../struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer">ParseBuffer</a>&lt;'a&gt;</h3></section></div><script src="../../../trait.impl/syn/parse/discouraged/trait.Speculative.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,116 @@
<!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="Parsing interface for parsing a token stream into a syntax tree node."><title>syn::parse - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Module parse</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module parse</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#the-synparse-functions" title="The `syn::parse*` functions">The <code>syn::parse*</code> functions</a></li><li><a href="#the-parser-trait" title="The `Parser` trait">The <code>Parser</code> trait</a></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate syn</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">syn</a></div><h1>Module <span>parse</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/syn/parse.rs.html#1-1420">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Parsing interface for parsing a token stream into a syntax tree node.</p>
<p>Parsing in Syn is built on parser functions that take in a <a href="type.ParseStream.html" title="type syn::parse::ParseStream"><code>ParseStream</code></a>
and produce a <a href="../type.Result.html" title="type syn::Result"><code>Result&lt;T&gt;</code></a> where <code>T</code> is some syntax tree node. Underlying
these parser functions is a lower level mechanism built around the
<a href="../buffer/struct.Cursor.html" title="struct syn::buffer::Cursor"><code>Cursor</code></a> type. <code>Cursor</code> is a cheaply copyable cursor over a range of
tokens in a token stream.</p>
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
<p>Here is a snippet of parsing code to get a feel for the style of the
library. We define data structures for a subset of Rust syntax including
enums (not shown) and structs, then provide implementations of the <a href="trait.Parse.html" title="trait syn::parse::Parse"><code>Parse</code></a>
trait to parse these syntax tree data structures from a token stream.</p>
<p>Once <code>Parse</code> impls have been defined, they can be called conveniently from a
procedural macro through <a href="../macro.parse_macro_input.html" title="macro syn::parse_macro_input"><code>parse_macro_input!</code></a> as shown at the bottom of
the snippet. If the caller provides syntactically invalid input to the
procedural macro, they will receive a helpful compiler error message
pointing out the exact token that triggered the failure to parse.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>proc_macro::TokenStream;
<span class="kw">use </span>syn::{braced, parse_macro_input, token, Field, Ident, <span class="prelude-ty">Result</span>, Token};
<span class="kw">use </span>syn::parse::{Parse, ParseStream};
<span class="kw">use </span>syn::punctuated::Punctuated;
<span class="kw">enum </span>Item {
Struct(ItemStruct),
Enum(ItemEnum),
}
<span class="kw">struct </span>ItemStruct {
struct_token: <span class="macro">Token!</span>[<span class="kw">struct</span>],
ident: Ident,
brace_token: token::Brace,
fields: Punctuated&lt;Field, <span class="macro">Token!</span>[,]&gt;,
}
<span class="kw">impl </span>Parse <span class="kw">for </span>Item {
<span class="kw">fn </span>parse(input: ParseStream) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">let </span>lookahead = input.lookahead1();
<span class="kw">if </span>lookahead.peek(<span class="macro">Token!</span>[<span class="kw">struct</span>]) {
input.parse().map(Item::Struct)
} <span class="kw">else if </span>lookahead.peek(<span class="macro">Token!</span>[<span class="kw">enum</span>]) {
input.parse().map(Item::Enum)
} <span class="kw">else </span>{
<span class="prelude-val">Err</span>(lookahead.error())
}
}
}
<span class="kw">impl </span>Parse <span class="kw">for </span>ItemStruct {
<span class="kw">fn </span>parse(input: ParseStream) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">let </span>content;
<span class="prelude-val">Ok</span>(ItemStruct {
struct_token: input.parse()<span class="question-mark">?</span>,
ident: input.parse()<span class="question-mark">?</span>,
brace_token: <span class="macro">braced!</span>(content <span class="kw">in </span>input),
fields: content.parse_terminated(Field::parse_named, <span class="macro">Token!</span>[,])<span class="question-mark">?</span>,
})
}
}
<span class="attr">#[proc_macro]
</span><span class="kw">pub fn </span>my_macro(tokens: TokenStream) -&gt; TokenStream {
<span class="kw">let </span>input = <span class="macro">parse_macro_input!</span>(tokens <span class="kw">as </span>Item);
<span class="comment">/* ... */
</span>}</code></pre></div><h2 id="the-synparse-functions"><a class="doc-anchor" href="#the-synparse-functions">§</a>The <code>syn::parse*</code> functions</h2>
<p>The <a href="../fn.parse.html" title="fn syn::parse"><code>syn::parse</code></a>, <a href="../fn.parse2.html" title="fn syn::parse2"><code>syn::parse2</code></a>, and <a href="../fn.parse_str.html" title="fn syn::parse_str"><code>syn::parse_str</code></a> functions serve
as an entry point for parsing syntax tree nodes that can be parsed in an
obvious default way. These functions can return any syntax tree node that
implements the <a href="trait.Parse.html" title="trait syn::parse::Parse"><code>Parse</code></a> trait, which includes most types in Syn.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>syn::Type;
<span class="kw">let </span>t: Type = syn::parse_str(<span class="string">"alloc::collections::HashMap&lt;String, Value&gt;"</span>)<span class="question-mark">?</span>;</code></pre></div>
<p>The <a href="../macro.parse_quote.html" title="macro syn::parse_quote"><code>parse_quote!</code></a> macro also uses this approach.</p>
<h2 id="the-parser-trait"><a class="doc-anchor" href="#the-parser-trait">§</a>The <code>Parser</code> trait</h2>
<p>Some types can be parsed in several ways depending on context. For example
an <a href="../struct.Attribute.html" title="struct syn::Attribute"><code>Attribute</code></a> can be either “outer” like <code>#[...]</code> or “inner” like
<code>#![...]</code> and parsing the wrong one would be a bug. Similarly <a href="../punctuated/index.html" title="mod syn::punctuated"><code>Punctuated</code></a>
may or may not allow trailing punctuation, and parsing it the wrong way
would either reject valid input or accept invalid input.</p>
<p>The <code>Parse</code> trait is not implemented in these cases because there is no good
behavior to consider the default.</p>
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile"></a><pre class="rust rust-example-rendered"><code><span class="comment">// Can't parse `Punctuated` without knowing whether trailing punctuation
// should be allowed in this context.
</span><span class="kw">let </span>path: Punctuated&lt;PathSegment, <span class="macro">Token!</span>[::]&gt; = syn::parse(tokens)<span class="question-mark">?</span>;</code></pre></div>
<p>In these cases the types provide a choice of parser functions rather than a
single <code>Parse</code> implementation, and those parser functions can be invoked
through the <a href="trait.Parser.html" title="trait syn::parse::Parser"><code>Parser</code></a> trait.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>proc_macro::TokenStream;
<span class="kw">use </span>syn::parse::Parser;
<span class="kw">use </span>syn::punctuated::Punctuated;
<span class="kw">use </span>syn::{Attribute, Expr, PathSegment, <span class="prelude-ty">Result</span>, Token};
<span class="kw">fn </span>call_some_parser_methods(input: TokenStream) -&gt; <span class="prelude-ty">Result</span>&lt;()&gt; {
<span class="comment">// Parse a nonempty sequence of path segments separated by `::` punctuation
// with no trailing punctuation.
</span><span class="kw">let </span>tokens = input.clone();
<span class="kw">let </span>parser = Punctuated::&lt;PathSegment, <span class="macro">Token!</span>[::]&gt;::parse_separated_nonempty;
<span class="kw">let </span>_path = parser.parse(tokens)<span class="question-mark">?</span>;
<span class="comment">// Parse a possibly empty sequence of expressions terminated by commas with
// an optional trailing punctuation.
</span><span class="kw">let </span>tokens = input.clone();
<span class="kw">let </span>parser = Punctuated::&lt;Expr, <span class="macro">Token!</span>[,]&gt;::parse_terminated;
<span class="kw">let </span>_args = parser.parse(tokens)<span class="question-mark">?</span>;
<span class="comment">// Parse zero or more outer attributes but not inner attributes.
</span><span class="kw">let </span>tokens = input.clone();
<span class="kw">let </span>parser = Attribute::parse_outer;
<span class="kw">let </span>_attrs = parser.parse(tokens)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</code></pre></div></div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="discouraged/index.html" title="mod syn::parse::discouraged">discouraged</a></dt><dd>Extensions to the parsing API with niche applicability.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.End.html" title="struct syn::parse::End">End</a></dt><dd>Pseudo-token used for peeking the end of a parse stream.</dd><dt><a class="struct" href="struct.Error.html" title="struct syn::parse::Error">Error</a></dt><dd>Error returned when a Syn parser cannot parse the input tokens.</dd><dt><a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a></dt><dd>Support for checking the next token in a stream to decide how to parse.</dd><dt><a class="struct" href="struct.Nothing.html" title="struct syn::parse::Nothing">Nothing</a></dt><dd>An empty syntax tree node that consumes no tokens when parsed.</dd><dt><a class="struct" href="struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer">Parse<wbr>Buffer</a></dt><dd>Cursor position within a buffered token stream.</dd><dt><a class="struct" href="struct.StepCursor.html" title="struct syn::parse::StepCursor">Step<wbr>Cursor</a></dt><dd>Cursor state associated with speculative parsing.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Parse.html" title="trait syn::parse::Parse">Parse</a></dt><dd>Parsing interface implemented by all types that can be parsed in a default
way from a token stream.</dd><dt><a class="trait" href="trait.Parser.html" title="trait syn::parse::Parser">Parser</a></dt><dd>Parser that can parse Rust tokens into a particular syntax tree node.</dd><dt><a class="trait" href="trait.Peek.html" title="trait syn::parse::Peek">Peek</a></dt><dd>Types that can be parsed by looking at just one token.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.ParseStream.html" title="type syn::parse::ParseStream">Parse<wbr>Stream</a></dt><dd>Input to a Syn parser function.</dd><dt><a class="type" href="type.Result.html" title="type syn::parse::Result">Result</a></dt><dd>The result of a Syn parser.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"mod":["discouraged"],"struct":["End","Error","Lookahead1","Nothing","ParseBuffer","StepCursor"],"trait":["Parse","Parser","Peek"],"type":["ParseStream","Result"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,69 @@
<!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="Support for checking the next token in a stream to decide how to parse."><title>Lookahead1 in syn::parse - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Lookahead1</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Lookahead1</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.error" title="error">error</a></li><li><a href="#method.peek" title="peek">peek</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Lookahead1%3C'a%3E" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Lookahead1%3C'a%3E" title="!RefUnwindSafe">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-Lookahead1%3C'a%3E" title="!Send">!Send</a></li><li><a href="#impl-Sync-for-Lookahead1%3C'a%3E" title="!Sync">!Sync</a></li><li><a href="#impl-Unpin-for-Lookahead1%3C'a%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Lookahead1%3C'a%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">syn</a>::<wbr><a href="index.html">parse</a></div><h1>Struct <span class="struct">Lookahead1</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/syn/lookahead.rs.html#65-69">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Lookahead1&lt;'a&gt; { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Support for checking the next token in a stream to decide how to parse.</p>
<p>An important advantage over <a href="struct.ParseBuffer.html#method.peek" title="method syn::parse::ParseBuffer::peek"><code>ParseStream::peek</code></a> is that here we
automatically construct an appropriate error message based on the token
alternatives that get peeked. If you are producing your own error message,
go ahead and use <code>ParseStream::peek</code> instead.</p>
<p>Use <a href="struct.ParseBuffer.html#method.lookahead1" title="method syn::parse::ParseBuffer::lookahead1"><code>ParseStream::lookahead1</code></a> to construct this object.</p>
<p>Consuming tokens from the source stream after constructing a lookahead
object does not also advance the lookahead object.</p>
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>syn::{ConstParam, Ident, Lifetime, LifetimeParam, <span class="prelude-ty">Result</span>, Token, TypeParam};
<span class="kw">use </span>syn::parse::{Parse, ParseStream};
<span class="comment">// A generic parameter, a single one of the comma-separated elements inside
// angle brackets in:
//
// fn f&lt;T: Clone, 'a, 'b: 'a, const N: usize&gt;() { ... }
//
// On invalid input, lookahead gives us a reasonable error message.
//
// error: expected one of: identifier, lifetime, `const`
// |
// 5 | fn f&lt;!Sized&gt;() {}
// | ^
</span><span class="kw">enum </span>GenericParam {
Type(TypeParam),
Lifetime(LifetimeParam),
Const(ConstParam),
}
<span class="kw">impl </span>Parse <span class="kw">for </span>GenericParam {
<span class="kw">fn </span>parse(input: ParseStream) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">let </span>lookahead = input.lookahead1();
<span class="kw">if </span>lookahead.peek(Ident) {
input.parse().map(GenericParam::Type)
} <span class="kw">else if </span>lookahead.peek(Lifetime) {
input.parse().map(GenericParam::Lifetime)
} <span class="kw">else if </span>lookahead.peek(<span class="macro">Token!</span>[<span class="kw">const</span>]) {
input.parse().map(GenericParam::Const)
} <span class="kw">else </span>{
<span class="prelude-val">Err</span>(lookahead.error())
}
}
}</code></pre></div></div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Lookahead1%3C'a%3E" class="impl"><a class="src rightside" href="../../src/syn/lookahead.rs.html#91-150">Source</a><a href="#impl-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.peek" class="method"><a class="src rightside" href="../../src/syn/lookahead.rs.html#106-109">Source</a><h4 class="code-header">pub fn <a href="#method.peek" class="fn">peek</a>&lt;T: <a class="trait" href="trait.Peek.html" title="trait syn::parse::Peek">Peek</a>&gt;(&amp;self, token: T) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Looks at the next token in the parse stream to determine whether it
matches the requested type of token.</p>
<h5 id="syntax"><a class="doc-anchor" href="#syntax">§</a>Syntax</h5>
<p>Note that this method does not use turbofish syntax. Pass the peek type
inside of parentheses.</p>
<ul>
<li><code>input.peek(Token![struct])</code></li>
<li><code>input.peek(Token![==])</code></li>
<li><code>input.peek(Ident)</code><em>(does not accept keywords)</em></li>
<li><code>input.peek(Ident::peek_any)</code></li>
<li><code>input.peek(Lifetime)</code></li>
<li><code>input.peek(token::Brace)</code></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.error" class="method"><a class="src rightside" href="../../src/syn/lookahead.rs.html#115-149">Source</a><h4 class="code-header">pub fn <a href="#method.error" class="fn">error</a>(self) -&gt; <a class="struct" href="../struct.Error.html" title="struct syn::Error">Error</a></h4></section></summary><div class="docblock"><p>Triggers an error at the current position of the parse stream.</p>
<p>The error message will identify all of the expected token types that
have been peeked against this lookahead instance.</p>
</div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Lookahead1%3C'a%3E" class="impl"><a href="#impl-Freeze-for-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section><section id="impl-RefUnwindSafe-for-Lookahead1%3C'a%3E" class="impl"><a href="#impl-RefUnwindSafe-for-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section><section id="impl-Send-for-Lookahead1%3C'a%3E" class="impl"><a href="#impl-Send-for-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section><section id="impl-Sync-for-Lookahead1%3C'a%3E" class="impl"><a href="#impl-Sync-for-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section><section id="impl-Unpin-for-Lookahead1%3C'a%3E" class="impl"><a href="#impl-Unpin-for-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section><section id="impl-UnwindSafe-for-Lookahead1%3C'a%3E" class="impl"><a href="#impl-UnwindSafe-for-Lookahead1%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Lookahead1.html" title="struct syn::parse::Lookahead1">Lookahead1</a>&lt;'a&gt;</h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
<!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="Parser that can parse Rust tokens into a particular syntax tree node."><title>Parser in syn::parse - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Parser</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Parser</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Output" title="Output">Output</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.parse2" title="parse2">parse2</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.parse" title="parse">parse</a></li><li><a href="#method.parse_str" title="parse_str">parse_str</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">syn</a>::<wbr><a href="index.html">parse</a></div><h1>Trait <span class="trait">Parser</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/syn/parse.rs.html#1240-1278">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Parser: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
type <a href="#associatedtype.Output" class="associatedtype">Output</a>;
// Required method
fn <a href="#tymethod.parse2" class="fn">parse2</a>(self, tokens: <a class="struct" href="../../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a>) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Parser.html#associatedtype.Output" title="type syn::parse::Parser::Output">Output</a>&gt;;
// Provided methods
fn <a href="#method.parse" class="fn">parse</a>(self, tokens: <a class="struct" href="https://doc.rust-lang.org/1.93.1/proc_macro/struct.TokenStream.html" title="struct proc_macro::TokenStream">TokenStream</a>) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Parser.html#associatedtype.Output" title="type syn::parse::Parser::Output">Output</a>&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.parse_str" class="fn">parse_str</a>(self, s: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Parser.html#associatedtype.Output" title="type syn::parse::Parser::Output">Output</a>&gt; { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Parser that can parse Rust tokens into a particular syntax tree node.</p>
<p>Refer to the <a href="index.html" title="mod syn::parse">module documentation</a> for details about parsing in Syn.</p>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><section id="associatedtype.Output" class="method"><a class="src rightside" href="../../src/syn/parse.rs.html#1241">Source</a><h4 class="code-header">type <a href="#associatedtype.Output" class="associatedtype">Output</a></h4></section></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.parse2" class="method"><a class="src rightside" href="../../src/syn/parse.rs.html#1247">Source</a><h4 class="code-header">fn <a href="#tymethod.parse2" class="fn">parse2</a>(self, tokens: <a class="struct" href="../../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a>) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Parser.html#associatedtype.Output" title="type syn::parse::Parser::Output">Output</a>&gt;</h4></section></summary><div class="docblock"><p>Parse a proc-macro2 token stream into the chosen syntax tree node.</p>
<p>This function enforces that the input is fully parsed. If there are any
unparsed tokens at the end of the stream, an error is returned.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.parse" class="method"><a class="src rightside" href="../../src/syn/parse.rs.html#1255-1257">Source</a><h4 class="code-header">fn <a href="#method.parse" class="fn">parse</a>(self, tokens: <a class="struct" href="https://doc.rust-lang.org/1.93.1/proc_macro/struct.TokenStream.html" title="struct proc_macro::TokenStream">TokenStream</a>) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Parser.html#associatedtype.Output" title="type syn::parse::Parser::Output">Output</a>&gt;</h4></section></summary><div class="docblock"><p>Parse tokens of source code into the chosen syntax tree node.</p>
<p>This function enforces that the input is fully parsed. If there are any
unparsed tokens at the end of the stream, an error is returned.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.parse_str" class="method"><a class="src rightside" href="../../src/syn/parse.rs.html#1268-1270">Source</a><h4 class="code-header">fn <a href="#method.parse_str" class="fn">parse_str</a>(self, s: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Parser.html#associatedtype.Output" title="type syn::parse::Parser::Output">Output</a>&gt;</h4></section></summary><div class="docblock"><p>Parse a string of Rust code into the chosen syntax tree node.</p>
<p>This function enforces that the input is fully parsed. If there are any
unparsed tokens at the end of the string, an error is returned.</p>
<h5 id="hygiene"><a class="doc-anchor" href="#hygiene">§</a>Hygiene</h5>
<p>Every span in the resulting syntax tree will be set to resolve at the
macro call site.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-Parser-for-F" class="impl"><a class="src rightside" href="../../src/syn/parse.rs.html#1287-1322">Source</a><a href="#impl-Parser-for-F" class="anchor">§</a><h3 class="code-header">impl&lt;F, T&gt; <a class="trait" href="trait.Parser.html" title="trait syn::parse::Parser">Parser</a> for F<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(<a class="type" href="type.ParseStream.html" title="type syn::parse::ParseStream">ParseStream</a>&lt;'_&gt;) -&gt; <a class="type" href="../type.Result.html" title="type syn::Result">Result</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Output-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/syn/parse.rs.html#1291">Source</a><a href="#associatedtype.Output-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></div></details></div><script src="../../trait.impl/syn/parse/trait.Parser.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,5 @@
<!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="Types that can be parsed by looking at just one token."><title>Peek in syn::parse - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Peek</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Peek</a></h2><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">syn</a>::<wbr><a href="index.html">parse</a></div><h1>Trait <span class="trait">Peek</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/syn/lookahead.rs.html#176-180">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Peek: Sealed { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Types that can be parsed by looking at just one token.</p>
<p>Use <a href="struct.ParseBuffer.html#method.peek" title="method syn::parse::ParseBuffer::peek"><code>ParseStream::peek</code></a> to peek one of these types in a parse stream
without consuming it from the stream.</p>
<p>This trait is sealed and cannot be implemented for types outside of Syn.</p>
</div></details><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Peek-for-End" class="impl"><a class="src rightside" href="../../src/syn/lookahead.rs.html#322-324">Source</a><a href="#impl-Peek-for-End" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Peek.html" title="trait syn::parse::Peek">Peek</a> for <a class="struct" href="struct.End.html" title="struct syn::parse::End">End</a></h3></section><section id="impl-Peek-for-F" class="impl"><a class="src rightside" href="../../src/syn/lookahead.rs.html#336-338">Source</a><a href="#impl-Peek-for-F" class="anchor">§</a><h3 class="code-header">impl&lt;F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(TokenMarker) -&gt; T, T: <a class="trait" href="../token/trait.Token.html" title="trait syn::token::Token">Token</a>&gt; <a class="trait" href="trait.Peek.html" title="trait syn::parse::Peek">Peek</a> for F</h3></section></div><script src="../../trait.impl/syn/lookahead/trait.Peek.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,4 @@
<!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="Input to a Syn parser function."><title>ParseStream in syn::parse - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">ParseStream</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">syn</a>::<wbr><a href="index.html">parse</a></div><h1>Type Alias <span class="type">Parse<wbr>Stream</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/syn/parse.rs.html#225">Source</a> </span></div><pre class="rust item-decl"><code>pub type ParseStream&lt;'a&gt; = &amp;'a <a class="struct" href="struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer">ParseBuffer</a>&lt;'a&gt;;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Input to a Syn parser function.</p>
<p>See the methods of this type under the documentation of <a href="struct.ParseBuffer.html" title="struct syn::parse::ParseBuffer"><code>ParseBuffer</code></a>. For
an overview of parsing in Syn, refer to the <a href="index.html" title="mod syn::parse">module documentation</a>.</p>
</div></details><script src="../../type.impl/syn/parse/struct.ParseBuffer.js" data-self-path="syn::parse::ParseStream" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,7 @@
<!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="The result of a Syn parser."><title>Result in syn::parse - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="syn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Result</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../syn/index.html">syn</a><span class="version">2.0.117</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Result</a></h2><h3><a href="#aliased-type">Aliased Type</a></h3><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.Err" title="Err">Err</a></li><li><a href="#variant.Ok" title="Ok">Ok</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In syn::<wbr>parse</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">syn</a>::<wbr><a href="index.html">parse</a></div><h1>Type Alias <span class="type">Result</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/syn/error.rs.html#19">Source</a> </span></div><pre class="rust item-decl"><code>pub type Result&lt;T&gt; = <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, <a class="struct" href="../struct.Error.html" title="struct syn::Error">Error</a>&gt;;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The result of a Syn parser.</p>
</div></details><h2 id="aliased-type" class="section-header">Aliased Type<a href="#aliased-type" class="anchor">§</a></h2><pre class="rust item-decl"><code>pub enum Result&lt;T&gt; {
Ok(T),
Err(<a class="struct" href="../struct.Error.html" title="struct syn::Error">Error</a>),
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Ok" class="variant"><a href="#variant.Ok" class="anchor">§</a><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h3 class="code-header">Ok(T)</h3></section><div class="docblock"><p>Contains the success value</p>
</div><section id="variant.Err" class="variant"><a href="#variant.Err" class="anchor">§</a><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h3 class="code-header">Err(<a class="struct" href="../struct.Error.html" title="struct syn::Error">Error</a>)</h3></section><div class="docblock"><p>Contains the error value</p>
</div></div><script src="../../type.impl/core/result/enum.Result.js" data-self-path="syn::error::Result" async></script></section></div></main></body></html>