<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="Types that can be interpolated inside a `quote!` invocation."><title>ToTokens in quote - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-dd39b87e5fcfba68.css"><metaname="rustdoc-vars"data-root-path="../"data-static-root-path="../static.files/"data-current-crate="quote"data-themes=""data-resource-suffix=""data-rustdoc-version="1.80.0 (051478957 2024-07-21)"data-channel="1.80.0"data-search-js="search-d52510db62a78183.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-118b08c4c78b968e.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../static.files/main-20a3ad099b048cf2.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-df360f571f6edeae.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle"title="show sidebar"></button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../quote/index.html">quote</a><spanclass="version">1.0.36</span></h2></div><h2class="location"><ahref="#">ToTokens</a></h2><divclass="sidebar-elems"><section><h3><ahref="#required-methods">Required Methods</a></h3><ulclass="block"><li><ahref="#tymethod.to_tokens">to_tokens</a></li></ul><h3><ahref="#provided-methods">Provided Methods</a></h3><ulclass="block"><li><ahref="#method.into_token_stream">into_token_stream</a></li><li><ahref="#method.to_token_stream">to_token_stream</a></li></ul><h3><ahref="#foreign-impls">Implementations on Foreign Types</a></h3><ulclass="block"><li><ahref="#impl-ToTokens-for-%26T">&'a T</a></li><li><ahref="#impl-ToTokens-for-%26mut+T">&'a mut T</a></li><li><ahref="#impl-ToTokens-for-Box%3CT%3E">Box<T></a></li><li><ahref="#impl-ToTokens-for-Cow%3C'a,+T%3E">Cow<'a, T></a></li><li><ahref="#impl-ToTokens-for-Group">Group</a></li><li><ahref="#impl-ToTokens-for-Ident">Ident</a></li><li><ahref="#impl-ToTokens-for-Literal">Literal</a></li><li><ahref="#impl-ToTokens-for-Option%3CT%3E">Option<T></a></li><li><ahref="#impl-ToTokens-for-Punct">Punct</a></li><li><ahref="#impl-ToTokens-for-Rc%3CT%3E">Rc<T></a></li><li><ahref="#impl-ToTokens-for-String">String</a></li><li><ahref="#impl-ToTokens-for-TokenStream">TokenStream</a></li><li><ahref="#impl-ToTokens-for-TokenTree">TokenTree</a></li><li><ahref="#impl-ToTokens-for-bool">bool</a></li><li><ahref="#impl-ToTokens-for-char">char</a></li><li><ahref="#impl-ToTokens-for-f32">f32</a></li><li><ahref="#impl-ToTokens-for-f64">f64</a></li><li><ahref="#impl-ToTokens-for-i128">i128</a></li><li><ahref="#impl-ToTokens-for-i16">i16</a></li><li><ahref="#impl-ToTokens-for-i32">i32</a></li><li><ahref="#impl-ToTokens-for-i64">i64</a></li><li><ahref="#impl-ToTokens-for-i8">i8</a></li><li><ahref="#impl-ToTokens-for-isize">isize</a></li><li><ahref="#impl-ToTokens-for-str">str</a></li><li><ahref="#impl-ToTokens-for-u128">u128</a></li><li><ahref="#impl-ToTokens-for-u16">u16</a></li><li><ahref="#impl-ToTokens-f
}</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>Types that can be interpolated inside a <code>quote!</code> invocation.</p>
</div></details><h2id="required-methods"class="section-header">Required Methods<ahref="#required-methods"class="anchor">§</a></h2><divclass="methods"><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.to_tokens"class="method"><aclass="src rightside"href="../src/quote/to_tokens.rs.html#53">source</a><h4class="code-header">fn <ahref="#tymethod.to_tokens"class="fn">to_tokens</a>(&self, tokens: &mut <aclass="struct"href="../proc_macro2/struct.TokenStream.html"title="struct proc_macro2::TokenStream">TokenStream</a>)</h4></section></summary><divclass="docblock"><p>Write <code>self</code> to the given <code>TokenStream</code>.</p>
<p>The token append methods provided by the <ahref="trait.TokenStreamExt.html"><code>TokenStreamExt</code></a> extension
trait may be useful for implementing <code>ToTokens</code>.</p>
Self: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><divclass="docblock"><p>Convert <code>self</code> directly into a <code>TokenStream</code> object.</p>