mirror of
https://github.com/trussed-dev/flexiber.git
synced 2026-03-11 16:35:17 -07:00
764 lines
96 KiB
HTML
764 lines
96 KiB
HTML
<!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="A wrapper around a `syn::DeriveInput` which provides utilities for creating custom derive trait implementations."><meta name="keywords" content="rust, rustlang, rust-lang, Structure"><title>Structure in synstructure - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-1f7d512b176f0f72.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/SourceSerif4-Bold-124a1ca42af929b6.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-6827029ac823cab7.css" id="mainThemeStyle"><link rel="stylesheet" id="themeStyle" href="../static.files/light-ebce58d0a40c3431.css"><link rel="stylesheet" disabled href="../static.files/dark-f23faae4a2daf9a6.css"><link rel="stylesheet" disabled href="../static.files/ayu-8af5e100b21cd173.css"><script id="default-settings" ></script><script src="../static.files/storage-d43fa987303ecbbb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-c55e1eb52e1886b4.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-13285aec31fa243e.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 struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../synstructure/index.html"><div class="logo-container"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../synstructure/index.html"><div class="logo-container"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></div></a><h2 class="location"><a href="#">Structure</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.add_bounds">add_bounds</a></li><li><a href="#method.add_impl_generic">add_impl_generic</a></li><li><a href="#method.add_trait_bounds">add_trait_bounds</a></li><li><a href="#method.add_where_predicate">add_where_predicate</a></li><li><a href="#method.ast">ast</a></li><li><a href="#method.bind_with">bind_with</a></li><li><a href="#method.binding_name">binding_name</a></li><li><a href="#method.bound_impl">bound_impl</a></li><li><a href="#method.each">each</a></li><li><a href="#method.each_variant">each_variant</a></li><li><a href="#method.filter">filter</a></li><li><a href="#method.filter_variants">filter_variants</a></li><li><a href="#method.fold">fold</a></li><li><a href="#method.gen_impl">gen_impl</a></li><li><a href="#method.new">new</a></li><li><a href="#method.omitted_variants">omitted_variants</a></li><li><a href="#method.referenced_ty_params">referenced_ty_params</a></li><li><a href="#method.remove_variant">remove_variant</a></li><li><a href="#method.try_new">try_new</a></li><li><a href="#method.unbound_impl">unbound_impl</a></li><li><a href="#method.underscore_const">underscore_const</a></li><li><a href="#method.unsafe_bound_impl">unsafe_bound_impl</a></li><li><a href="#method.unsafe_unbound_impl">unsafe_unbound_impl</a></li><li><a href="#method.variants">variants</a></li><li><a href="#method.variants_mut">variants_mut</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Clone-for-Structure%3C%27a%3E">Clone</a></li><li><a href="#impl-Debug-for-Structure%3C%27a%3E">Debug</a></li><li><a href="#impl-Eq-for-Structure%3C%27a%3E">Eq</a></li><li><a href="#impl-Hash-for-Structure%3C%27a%3E">Hash</a></li><li><a href="#impl-PartialEq%3CStructure%3C%27a%3E%3E-for-Structure%3C%27a%3E">PartialEq<Structure<'a>></a></li><li><a href="#impl-StructuralEq-for-Structure%3C%27a%3E">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-Structure%3C%27a%3E">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Structure%3C%27a%3E">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Structure%3C%27a%3E">!Send</a></li><li><a href="#impl-Sync-for-Structure%3C%27a%3E">!Sync</a></li><li><a href="#impl-Unpin-for-Structure%3C%27a%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Structure%3C%27a%3E">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Structure%3C%27a%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Structure%3C%27a%3E">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Structure%3C%27a%3E">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Structure%3C%27a%3E">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Structure%3C%27a%3E">Into<U></a></li><li><a href="#impl-ToOwned-for-Structure%3C%27a%3E">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Structure%3C%27a%3E">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Structure%3C%27a%3E">TryInto<U></a></li></ul></section><h2><a href="index.html">In synstructure</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><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" title="help" tabindex="-1"><a href="../help.html">?</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-5ec35bf9ca753509.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">synstructure</a>::<wbr><a class="struct" href="#">Structure</a><button id="copy-path" onclick="copy_path(this)" 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="srclink" href="../src/synstructure/lib.rs.html#939-947">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Structure<'a> { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A wrapper around a <code>syn::DeriveInput</code> which provides utilities for creating
|
||
custom derive trait implementations.</p>
|
||
</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#949-2310">source</a><a href="#impl-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#957-959">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(ast: &'a <a class="struct" href="../syn/derive/struct.DeriveInput.html" title="struct syn::derive::DeriveInput">DeriveInput</a>) -> Self</h4></section></summary><div class="docblock"><p>Create a new <code>Structure</code> with the variants and fields from the passed-in
|
||
<code>DeriveInput</code>.</p>
|
||
<h5 id="panics"><a href="#panics">Panics</a></h5>
|
||
<p>This method will panic if the provided AST node represents an untagged
|
||
union.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_new" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#966-1021">source</a><h4 class="code-header">pub fn <a href="#method.try_new" class="fn">try_new</a>(ast: &'a <a class="struct" href="../syn/derive/struct.DeriveInput.html" title="struct syn::derive::DeriveInput">DeriveInput</a>) -> <a class="type" href="../syn/error/type.Result.html" title="type syn::error::Result">Result</a><Self></h4></section></summary><div class="docblock"><p>Create a new <code>Structure</code> with the variants and fields from the passed-in
|
||
<code>DeriveInput</code>.</p>
|
||
<p>Unlike <code>Structure::new</code>, this method does not panic if the provided AST
|
||
node represents an untagged union.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.variants" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1024-1026">source</a><h4 class="code-header">pub fn <a href="#method.variants" class="fn">variants</a>(&self) -> &[<a class="struct" href="struct.VariantInfo.html" title="struct synstructure::VariantInfo">VariantInfo</a><'a>]</h4></section></summary><div class="docblock"><p>Returns a slice of the variants in this Structure.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.variants_mut" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1029-1031">source</a><h4 class="code-header">pub fn <a href="#method.variants_mut" class="fn">variants_mut</a>(&mut self) -> &mut [<a class="struct" href="struct.VariantInfo.html" title="struct synstructure::VariantInfo">VariantInfo</a><'a>]</h4></section></summary><div class="docblock"><p>Returns a mut slice of the variants in this Structure.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ast" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1035-1037">source</a><h4 class="code-header">pub fn <a href="#method.ast" class="fn">ast</a>(&self) -> &'a <a class="struct" href="../syn/derive/struct.DeriveInput.html" title="struct syn::derive::DeriveInput">DeriveInput</a></h4></section></summary><div class="docblock"><p>Returns a reference to the underlying <code>syn</code> AST node which this
|
||
<code>Structure</code> was created from.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.omitted_variants" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1040-1042">source</a><h4 class="code-header">pub fn <a href="#method.omitted_variants" class="fn">omitted_variants</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>True if any variants were omitted due to a <code>filter_variants</code> call.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.each" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1075-1088">source</a><h4 class="code-header">pub fn <a href="#method.each" class="fn">each</a><F, R>(&self, f: F) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a><span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&<a class="struct" href="struct.BindingInfo.html" title="struct synstructure::BindingInfo">BindingInfo</a><'_>) -> R,<br> R: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>,</span></h4></section></summary><div class="docblock"><p>Runs the passed-in function once for each bound field, passing in a <code>BindingInfo</code>.
|
||
and generating <code>match</code> arms which evaluate the returned tokens.</p>
|
||
<p>This method will ignore variants or fields which are ignored through the
|
||
<code>filter</code> and <code>filter_variant</code> methods.</p>
|
||
<h5 id="example"><a href="#example">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B(i32, i32),
|
||
C(u32),
|
||
}
|
||
};
|
||
<span class="kw">let </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.each(|bi| <span class="macro">quote!</span>(<span class="macro">println!</span>(<span class="string">"{:?}"</span>, #bi))).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::B(<span class="kw-2">ref </span>__binding_0, <span class="kw-2">ref </span>__binding_1,) => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_1) }
|
||
}
|
||
A::C(<span class="kw-2">ref </span>__binding_0,) => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fold" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1123-1137">source</a><h4 class="code-header">pub fn <a href="#method.fold" class="fn">fold</a><F, I, R>(&self, init: I, f: F) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a><span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a>, &<a class="struct" href="struct.BindingInfo.html" title="struct synstructure::BindingInfo">BindingInfo</a><'_>) -> R,<br> I: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>,<br> R: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>,</span></h4></section></summary><div class="docblock"><p>Runs the passed-in function once for each bound field, passing in the
|
||
result of the previous call, and a <code>BindingInfo</code>. generating <code>match</code>
|
||
arms which evaluate to the resulting tokens.</p>
|
||
<p>This method will ignore variants or fields which are ignored through the
|
||
<code>filter</code> and <code>filter_variant</code> methods.</p>
|
||
<p>If a variant has been ignored, it will return the <code>init</code> value.</p>
|
||
<h5 id="example-1"><a href="#example-1">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B(i32, i32),
|
||
C(u32),
|
||
}
|
||
};
|
||
<span class="kw">let </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.fold(<span class="macro">quote!</span>(<span class="number">0</span>), |acc, bi| <span class="macro">quote!</span>(#acc + #bi)).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::B(<span class="kw-2">ref </span>__binding_0, <span class="kw-2">ref </span>__binding_1,) => {
|
||
<span class="number">0 </span>+ __binding_0 + __binding_1
|
||
}
|
||
A::C(<span class="kw-2">ref </span>__binding_0,) => {
|
||
<span class="number">0 </span>+ __binding_0
|
||
}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.each_variant" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1173-1188">source</a><h4 class="code-header">pub fn <a href="#method.each_variant" class="fn">each_variant</a><F, R>(&self, f: F) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a><span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&<a class="struct" href="struct.VariantInfo.html" title="struct synstructure::VariantInfo">VariantInfo</a><'_>) -> R,<br> R: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>,</span></h4></section></summary><div class="docblock"><p>Runs the passed-in function once for each variant, passing in a
|
||
<code>VariantInfo</code>. and generating <code>match</code> arms which evaluate the returned
|
||
tokens.</p>
|
||
<p>This method will ignore variants and not bind fields which are ignored
|
||
through the <code>filter</code> and <code>filter_variant</code> methods.</p>
|
||
<h5 id="example-2"><a href="#example-2">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B(i32, i32),
|
||
C(u32),
|
||
}
|
||
};
|
||
<span class="kw">let </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.each_variant(|v| {
|
||
<span class="kw">let </span>name = <span class="kw-2">&</span>v.ast().ident;
|
||
<span class="macro">quote!</span>(<span class="macro">println!</span>(<span class="macro">stringify!</span>(#name)))
|
||
}).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::B(<span class="kw-2">ref </span>__binding_0, <span class="kw-2">ref </span>__binding_1,) => {
|
||
<span class="macro">println!</span>(<span class="macro">stringify!</span>(B))
|
||
}
|
||
A::C(<span class="kw-2">ref </span>__binding_0,) => {
|
||
<span class="macro">println!</span>(<span class="macro">stringify!</span>(C))
|
||
}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.filter" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1227-1235">source</a><h4 class="code-header">pub fn <a href="#method.filter" class="fn">filter</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self<span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&<a class="struct" href="struct.BindingInfo.html" title="struct synstructure::BindingInfo">BindingInfo</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.bool.html">bool</a>,</span></h4></section></summary><div class="docblock"><p>Filter the bindings created by this <code>Structure</code> object. This has 2 effects:</p>
|
||
<ul>
|
||
<li>
|
||
<p>The bindings will no longer appear in match arms generated by methods
|
||
on this <code>Structure</code> or its subobjects.</p>
|
||
</li>
|
||
<li>
|
||
<p>Impl blocks created with the <code>bound_impl</code> or <code>unsafe_bound_impl</code>
|
||
method only consider type parameters referenced in the types of
|
||
non-filtered fields.</p>
|
||
</li>
|
||
</ul>
|
||
<h5 id="example-3"><a href="#example-3">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B{ a: i32, b: i32 },
|
||
C{ a: u32 },
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter(|bi| {
|
||
bi.ast().ident == <span class="prelude-val">Some</span>(<span class="macro">quote::format_ident!</span>(<span class="string">"a"</span>))
|
||
});
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.each(|bi| <span class="macro">quote!</span>(<span class="macro">println!</span>(<span class="string">"{:?}"</span>, #bi))).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::B{ a: <span class="kw-2">ref </span>__binding_0, .. } => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
}
|
||
A::C{ a: <span class="kw-2">ref </span>__binding_0, } => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_where_predicate" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1276-1279">source</a><h4 class="code-header">pub fn <a href="#method.add_where_predicate" class="fn">add_where_predicate</a>(&mut self, pred: <a class="enum" href="../syn/generics/enum.WherePredicate.html" title="enum syn::generics::WherePredicate">WherePredicate</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self</h4></section></summary><div class="docblock"><p>Specify additional where predicate bounds which should be generated by
|
||
impl-generating functions such as <code>gen_impl</code>, <code>bound_impl</code>, and
|
||
<code>unsafe_bound_impl</code>.</p>
|
||
<h5 id="example-4"><a href="#example-4">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
<span class="comment">// Add an additional where predicate.
|
||
</span>s.add_where_predicate(<span class="macro">syn::parse_quote!</span>(T: std::fmt::Display));
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.bound_impl(<span class="macro">quote!</span>(krate::Trait), <span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where </span>T: std::fmt::Display,
|
||
T: krate::Trait,
|
||
<span class="prelude-ty">Option</span><U>: krate::Trait,
|
||
U: krate::Trait
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_bounds" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1320-1323">source</a><h4 class="code-header">pub fn <a href="#method.add_bounds" class="fn">add_bounds</a>(&mut self, mode: <a class="enum" href="enum.AddBounds.html" title="enum synstructure::AddBounds">AddBounds</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self</h4></section></summary><div class="docblock"><p>Specify which bounds should be generated by impl-generating functions
|
||
such as <code>gen_impl</code>, <code>bound_impl</code>, and <code>unsafe_bound_impl</code>.</p>
|
||
<p>The default behaviour is to generate both field and generic bounds from
|
||
type parameters.</p>
|
||
<h5 id="example-5"><a href="#example-5">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
<span class="comment">// Limit bounds to only generics.
|
||
</span>s.add_bounds(AddBounds::Generics);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.bound_impl(<span class="macro">quote!</span>(krate::Trait), <span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where </span>T: krate::Trait,
|
||
U: krate::Trait
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.filter_variants" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1359-1369">source</a><h4 class="code-header">pub fn <a href="#method.filter_variants" class="fn">filter_variants</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self<span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&<a class="struct" href="struct.VariantInfo.html" title="struct synstructure::VariantInfo">VariantInfo</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.bool.html">bool</a>,</span></h4></section></summary><div class="docblock"><p>Filter the variants matched by this <code>Structure</code> object. This has 2 effects:</p>
|
||
<ul>
|
||
<li>
|
||
<p>Match arms destructuring these variants will no longer be generated by
|
||
methods on this <code>Structure</code></p>
|
||
</li>
|
||
<li>
|
||
<p>Impl blocks created with the <code>bound_impl</code> or <code>unsafe_bound_impl</code>
|
||
method only consider type parameters referenced in the types of
|
||
fields in non-fitered variants.</p>
|
||
</li>
|
||
</ul>
|
||
<h5 id="example-6"><a href="#example-6">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B(i32, i32),
|
||
C(u32),
|
||
}
|
||
};
|
||
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"B"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.each(|bi| <span class="macro">quote!</span>(<span class="macro">println!</span>(<span class="string">"{:?}"</span>, #bi))).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::C(<span class="kw-2">ref </span>__binding_0,) => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
}
|
||
<span class="kw">_ </span>=> {}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.remove_variant" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1376-1380">source</a><h4 class="code-header">pub fn <a href="#method.remove_variant" class="fn">remove_variant</a>(&mut self, idx: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self</h4></section></summary><div class="docblock"><p>Remove the variant at the given index.</p>
|
||
<h5 id="panics-1"><a href="#panics-1">Panics</a></h5>
|
||
<p>Panics if the index is out of range.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.bind_with" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1412-1420">source</a><h4 class="code-header">pub fn <a href="#method.bind_with" class="fn">bind_with</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self<span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&<a class="struct" href="struct.BindingInfo.html" title="struct synstructure::BindingInfo">BindingInfo</a><'_>) -> <a class="enum" href="enum.BindStyle.html" title="enum synstructure::BindStyle">BindStyle</a>,</span></h4></section></summary><div class="docblock"><p>Updates the <code>BindStyle</code> for each of the passed-in fields by calling the
|
||
passed-in function for each <code>BindingInfo</code>.</p>
|
||
<h5 id="example-7"><a href="#example-7">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B(i32, i32),
|
||
C(u32),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.bind_with(|bi| BindStyle::RefMut);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.each(|bi| <span class="macro">quote!</span>(<span class="macro">println!</span>(<span class="string">"{:?}"</span>, #bi))).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::B(<span class="kw-2">ref mut </span>__binding_0, <span class="kw-2">ref mut </span>__binding_1,) => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_1) }
|
||
}
|
||
A::C(<span class="kw-2">ref mut </span>__binding_0,) => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, __binding_0) }
|
||
}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.binding_name" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1458-1466">source</a><h4 class="code-header">pub fn <a href="#method.binding_name" class="fn">binding_name</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self<span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&<a class="struct" href="../syn/data/struct.Field.html" title="struct syn::data::Field">Field</a>, <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../proc_macro2/struct.Ident.html" title="struct proc_macro2::Ident">Ident</a>,</span></h4></section></summary><div class="docblock"><p>Updates the binding name for each fo the passed-in fields by calling the
|
||
passed-in function for each <code>BindingInfo</code>.</p>
|
||
<p>The function will be called with the <code>BindingInfo</code> and its index in the
|
||
enclosing variant.</p>
|
||
<p>The default name is <code>__binding_{}</code> where <code>{}</code> is replaced with an
|
||
increasing number.</p>
|
||
<h5 id="example-8"><a href="#example-8">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A {
|
||
B{ a: i32, b: i32 },
|
||
C{ a: u32 },
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.binding_name(|bi, i| bi.ident.clone().unwrap());
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.each(|bi| <span class="macro">quote!</span>(<span class="macro">println!</span>(<span class="string">"{:?}"</span>, #bi))).to_string(),
|
||
|
||
<span class="macro">quote!</span>{
|
||
A::B{ a: <span class="kw-2">ref </span>a, b: <span class="kw-2">ref </span>b, } => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, a) }
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, b) }
|
||
}
|
||
A::C{ a: <span class="kw-2">ref </span>a, } => {
|
||
{ <span class="macro">println!</span>(<span class="string">"{:?}"</span>, a) }
|
||
}
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.referenced_ty_params" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1495-1503">source</a><h4 class="code-header">pub fn <a href="#method.referenced_ty_params" class="fn">referenced_ty_params</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.67.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><&'a <a class="struct" href="../proc_macro2/struct.Ident.html" title="struct proc_macro2::Ident">Ident</a>></h4></section></summary><div class="docblock"><p>Returns a list of the type parameters which are refrenced in the types
|
||
of non-filtered fields / variants.</p>
|
||
<h5 id="caveat"><a href="#caveat">Caveat</a></h5>
|
||
<p>If the struct contains any macros in type position, all parameters will
|
||
be considered bound. This is because we cannot determine which type
|
||
parameters are bound by type macros.</p>
|
||
<h5 id="example-9"><a href="#example-9">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T, i32),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"C"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.referenced_ty_params(),
|
||
<span class="kw-2">&</span>[<span class="kw-2">&</span><span class="macro">quote::format_ident!</span>(<span class="string">"T"</span>)]
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_impl_generic" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1543-1546">source</a><h4 class="code-header">pub fn <a href="#method.add_impl_generic" class="fn">add_impl_generic</a>(&mut self, param: <a class="enum" href="../syn/generics/enum.GenericParam.html" title="enum syn::generics::GenericParam">GenericParam</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self</h4></section></summary><div class="docblock"><p>Adds an <code>impl<></code> generic parameter.
|
||
This can be used when the trait to be derived needs some extra generic parameters.</p>
|
||
<h5 id="example-10"><a href="#example-10">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
<span class="kw">let </span>generic: syn::GenericParam = <span class="macro">syn::parse_quote!</span>(X: krate::AnotherTrait);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.add_impl_generic(generic)
|
||
.bound_impl(<span class="macro">quote!</span>(krate::Trait<X>),
|
||
<span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_X_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U, X: krate::AnotherTrait> krate::Trait<X> <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where </span>T : krate :: Trait < X >,
|
||
<span class="prelude-ty">Option</span><U>: krate::Trait<X>,
|
||
U: krate::Trait<X>
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_trait_bounds" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1556-1621">source</a><h4 class="code-header">pub fn <a href="#method.add_trait_bounds" class="fn">add_trait_bounds</a>(<br> &self,<br> bound: &<a class="struct" href="../syn/generics/struct.TraitBound.html" title="struct syn::generics::TraitBound">TraitBound</a>,<br> where_clause: &mut <a class="enum" href="https://doc.rust-lang.org/1.67.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../syn/generics/struct.WhereClause.html" title="struct syn::generics::WhereClause">WhereClause</a>>,<br> mode: <a class="enum" href="enum.AddBounds.html" title="enum synstructure::AddBounds">AddBounds</a><br>)</h4></section></summary><div class="docblock"><p>Add trait bounds for a trait with the given path for each type parmaeter
|
||
referenced in the types of non-filtered fields.</p>
|
||
<h5 id="caveat-1"><a href="#caveat-1">Caveat</a></h5>
|
||
<p>If the method contains any macros in type position, all parameters will
|
||
be considered bound. This is because we cannot determine which type
|
||
parameters are bound by type macros.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.underscore_const" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1664-1667">source</a><h4 class="code-header">pub fn <a href="#method.underscore_const" class="fn">underscore_const</a>(&mut self, enabled: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.bool.html">bool</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>Self</h4></section></summary><div class="docblock"><p>Configure whether to use <code>const _</code> instead of a generated const name in
|
||
code generated by <code>gen_impl</code> and <code>bound_impl</code>.</p>
|
||
<p>This syntax is only supported by rust 1.37, and later versions.</p>
|
||
<p>Defaults to <code>false</code> for backwards compatibility reasons.</p>
|
||
<h5 id="example-11"><a href="#example-11">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">struct </span>MyStruct;
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.underscore_const(<span class="bool-val">true</span>)
|
||
.gen_impl(<span class="macro">quote! </span>{ gen <span class="kw">impl </span>Trait <span class="kw">for </span>@<span class="self">Self </span>{ } })
|
||
.to_string(),
|
||
<span class="macro">quote! </span>{
|
||
<span class="kw">const _</span>: () = {
|
||
<span class="kw">impl </span>Trait <span class="kw">for </span>MyStruct { }
|
||
};
|
||
}
|
||
.to_string()
|
||
);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.underscore_const(<span class="bool-val">false</span>)
|
||
.gen_impl(<span class="macro">quote! </span>{ gen <span class="kw">impl </span>Trait <span class="kw">for </span>@<span class="self">Self </span>{ } })
|
||
.to_string(),
|
||
<span class="macro">quote! </span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
</span><span class="kw">const </span>_DERIVE_Trait_FOR_MyStruct: () = {
|
||
<span class="kw">impl </span>Trait <span class="kw">for </span>MyStruct { }
|
||
};
|
||
}
|
||
.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.bound_impl" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1730-1737">source</a><h4 class="code-header">pub fn <a href="#method.bound_impl" class="fn">bound_impl</a><P: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>, B: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>>(<br> &self,<br> path: P,<br> body: B<br>) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a></h4></section></summary><div class="docblock"><blockquote>
|
||
<p>NOTE: This methods’ features are superceded by <code>Structure::gen_impl</code>.</p>
|
||
</blockquote>
|
||
<p>Creates an <code>impl</code> block with the required generic type fields filled in
|
||
to implement the trait <code>path</code>.</p>
|
||
<p>This method also adds where clauses to the impl requiring that all
|
||
referenced type parmaeters implement the trait <code>path</code>.</p>
|
||
<h5 id="hygiene-and-paths"><a href="#hygiene-and-paths">Hygiene and Paths</a></h5>
|
||
<p>This method wraps the impl block inside of a <code>const</code> (see the example
|
||
below). In this scope, the first segment of the passed-in path is
|
||
<code>extern crate</code>-ed in. If you don’t want to generate that <code>extern crate</code>
|
||
item, use a global path.</p>
|
||
<p>This means that if you are implementing <code>my_crate::Trait</code>, you simply
|
||
write <code>s.bound_impl(quote!(my_crate::Trait), quote!(...))</code>, and for the
|
||
entirety of the definition, you can refer to your crate as <code>my_crate</code>.</p>
|
||
<h5 id="caveat-2"><a href="#caveat-2">Caveat</a></h5>
|
||
<p>If the method contains any macros in type position, all parameters will
|
||
be considered bound. This is because we cannot determine which type
|
||
parameters are bound by type macros.</p>
|
||
<h5 id="panics-2"><a href="#panics-2">Panics</a></h5>
|
||
<p>Panics if the path string parameter is not a valid <code>TraitBound</code>.</p>
|
||
<h5 id="example-12"><a href="#example-12">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"B"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.bound_impl(<span class="macro">quote!</span>(krate::Trait), <span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where </span><span class="prelude-ty">Option</span><U>: krate::Trait,
|
||
U: krate::Trait
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unsafe_bound_impl" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1800-1807">source</a><h4 class="code-header">pub fn <a href="#method.unsafe_bound_impl" class="fn">unsafe_bound_impl</a><P: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>, B: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>>(<br> &self,<br> path: P,<br> body: B<br>) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a></h4></section></summary><div class="docblock"><blockquote>
|
||
<p>NOTE: This methods’ features are superceded by <code>Structure::gen_impl</code>.</p>
|
||
</blockquote>
|
||
<p>Creates an <code>impl</code> block with the required generic type fields filled in
|
||
to implement the unsafe trait <code>path</code>.</p>
|
||
<p>This method also adds where clauses to the impl requiring that all
|
||
referenced type parmaeters implement the trait <code>path</code>.</p>
|
||
<h5 id="hygiene-and-paths-1"><a href="#hygiene-and-paths-1">Hygiene and Paths</a></h5>
|
||
<p>This method wraps the impl block inside of a <code>const</code> (see the example
|
||
below). In this scope, the first segment of the passed-in path is
|
||
<code>extern crate</code>-ed in. If you don’t want to generate that <code>extern crate</code>
|
||
item, use a global path.</p>
|
||
<p>This means that if you are implementing <code>my_crate::Trait</code>, you simply
|
||
write <code>s.bound_impl(quote!(my_crate::Trait), quote!(...))</code>, and for the
|
||
entirety of the definition, you can refer to your crate as <code>my_crate</code>.</p>
|
||
<h5 id="caveat-3"><a href="#caveat-3">Caveat</a></h5>
|
||
<p>If the method contains any macros in type position, all parameters will
|
||
be considered bound. This is because we cannot determine which type
|
||
parameters are bound by type macros.</p>
|
||
<h5 id="panics-3"><a href="#panics-3">Panics</a></h5>
|
||
<p>Panics if the path string parameter is not a valid <code>TraitBound</code>.</p>
|
||
<h5 id="example-13"><a href="#example-13">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"B"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.unsafe_bound_impl(<span class="macro">quote!</span>(krate::Trait), <span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">unsafe impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where </span><span class="prelude-ty">Option</span><U>: krate::Trait,
|
||
U: krate::Trait
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unbound_impl" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1860-1867">source</a><h4 class="code-header">pub fn <a href="#method.unbound_impl" class="fn">unbound_impl</a><P: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>, B: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>>(<br> &self,<br> path: P,<br> body: B<br>) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a></h4></section></summary><div class="docblock"><blockquote>
|
||
<p>NOTE: This methods’ features are superceded by <code>Structure::gen_impl</code>.</p>
|
||
</blockquote>
|
||
<p>Creates an <code>impl</code> block with the required generic type fields filled in
|
||
to implement the trait <code>path</code>.</p>
|
||
<p>This method will not add any where clauses to the impl.</p>
|
||
<h5 id="hygiene-and-paths-2"><a href="#hygiene-and-paths-2">Hygiene and Paths</a></h5>
|
||
<p>This method wraps the impl block inside of a <code>const</code> (see the example
|
||
below). In this scope, the first segment of the passed-in path is
|
||
<code>extern crate</code>-ed in. If you don’t want to generate that <code>extern crate</code>
|
||
item, use a global path.</p>
|
||
<p>This means that if you are implementing <code>my_crate::Trait</code>, you simply
|
||
write <code>s.bound_impl(quote!(my_crate::Trait), quote!(...))</code>, and for the
|
||
entirety of the definition, you can refer to your crate as <code>my_crate</code>.</p>
|
||
<h5 id="panics-4"><a href="#panics-4">Panics</a></h5>
|
||
<p>Panics if the path string parameter is not a valid <code>TraitBound</code>.</p>
|
||
<h5 id="example-14"><a href="#example-14">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"B"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.unbound_impl(<span class="macro">quote!</span>(krate::Trait), <span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U> {
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unsafe_unbound_impl" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#1921-1928">source</a><h4 class="code-header">pub fn <a href="#method.unsafe_unbound_impl" class="fn">unsafe_unbound_impl</a><P: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>, B: <a class="trait" href="../quote/to_tokens/trait.ToTokens.html" title="trait quote::to_tokens::ToTokens">ToTokens</a>>(<br> &self,<br> path: P,<br> body: B<br>) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated</span></div></span></summary><div class="docblock"><blockquote>
|
||
<p>NOTE: This methods’ features are superceded by <code>Structure::gen_impl</code>.</p>
|
||
</blockquote>
|
||
<p>Creates an <code>impl</code> block with the required generic type fields filled in
|
||
to implement the unsafe trait <code>path</code>.</p>
|
||
<p>This method will not add any where clauses to the impl.</p>
|
||
<h5 id="hygiene-and-paths-3"><a href="#hygiene-and-paths-3">Hygiene and Paths</a></h5>
|
||
<p>This method wraps the impl block inside of a <code>const</code> (see the example
|
||
below). In this scope, the first segment of the passed-in path is
|
||
<code>extern crate</code>-ed in. If you don’t want to generate that <code>extern crate</code>
|
||
item, use a global path.</p>
|
||
<p>This means that if you are implementing <code>my_crate::Trait</code>, you simply
|
||
write <code>s.bound_impl(quote!(my_crate::Trait), quote!(...))</code>, and for the
|
||
entirety of the definition, you can refer to your crate as <code>my_crate</code>.</p>
|
||
<h5 id="panics-5"><a href="#panics-5">Panics</a></h5>
|
||
<p>Panics if the path string parameter is not a valid <code>TraitBound</code>.</p>
|
||
<h5 id="example-15"><a href="#example-15">Example</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"B"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.unsafe_unbound_impl(<span class="macro">quote!</span>(krate::Trait), <span class="macro">quote!</span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
#[doc(hidden)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">unsafe impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U> {
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gen_impl" class="method has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#2205-2211">source</a><h4 class="code-header">pub fn <a href="#method.gen_impl" class="fn">gen_impl</a>(&self, cfg: <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a>) -> <a class="struct" href="../proc_macro2/struct.TokenStream.html" title="struct proc_macro2::TokenStream">TokenStream</a></h4></section></summary><div class="docblock"><p>Generate an impl block for the given struct. This impl block will
|
||
automatically use hygiene tricks to avoid polluting the caller’s
|
||
namespace, and will automatically add trait bounds for generic type
|
||
parameters.</p>
|
||
<h5 id="syntax"><a href="#syntax">Syntax</a></h5>
|
||
<p>This function accepts its arguments as a <code>TokenStream</code>. The recommended way
|
||
to call this function is passing the result of invoking the <code>quote!</code>
|
||
macro to it.</p>
|
||
|
||
<div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code>s.gen_impl(<span class="macro">quote! </span>{
|
||
<span class="comment">// You can write any items which you want to import into scope here.
|
||
// For example, you may want to include an `extern crate` for the
|
||
// crate which implements your trait. These items will only be
|
||
// visible to the code you generate, and won't be exposed to the
|
||
// consuming crate
|
||
</span><span class="kw">extern crate </span>krate;
|
||
|
||
<span class="comment">// You can also add `use` statements here to bring types or traits
|
||
// into scope.
|
||
//
|
||
// WARNING: Try not to use common names here, because the stable
|
||
// version of syn does not support hygiene and you could accidentally
|
||
// shadow types from the caller crate.
|
||
</span><span class="kw">use </span>krate::Trait <span class="kw">as </span>MyTrait;
|
||
|
||
<span class="comment">// The actual impl block is a `gen impl` or `gen unsafe impl` block.
|
||
// You can use `@Self` to refer to the structure's type.
|
||
</span>gen <span class="kw">impl </span>MyTrait <span class="kw">for </span>@<span class="self">Self </span>{
|
||
<span class="kw">fn </span>f(<span class="kw-2">&</span><span class="self">self</span>) { ... }
|
||
}
|
||
})</code></pre></div>
|
||
<p>The most common usage of this trait involves loading the crate the
|
||
target trait comes from with <code>extern crate</code>, and then invoking a <code>gen impl</code> block.</p>
|
||
<h5 id="hygiene"><a href="#hygiene">Hygiene</a></h5>
|
||
<p>This method tries to handle hygiene intelligenly for both stable and
|
||
unstable proc-macro implementations, however there are visible
|
||
differences.</p>
|
||
<p>The output of every <code>gen_impl</code> function is wrapped in a dummy <code>const</code>
|
||
value, to ensure that it is given its own scope, and any values brought
|
||
into scope are not leaked to the calling crate.</p>
|
||
<p>By default, the above invocation may generate an output like the
|
||
following:</p>
|
||
|
||
<div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="kw">const </span>_DERIVE_krate_Trait_FOR_Struct: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">use </span>krate::Trait <span class="kw">as </span>MyTrait;
|
||
<span class="kw">impl</span><T> MyTrait <span class="kw">for </span>Struct<T> <span class="kw">where </span>T: MyTrait {
|
||
<span class="kw">fn </span>f(<span class="kw-2">&</span><span class="self">self</span>) { ... }
|
||
}
|
||
};</code></pre></div>
|
||
<p>The <code>Structure</code> may also be confired with the [<code>underscore_const</code>] method
|
||
to generate <code>const _</code> instead.</p>
|
||
|
||
<div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="kw">const _</span>: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">use </span>krate::Trait <span class="kw">as </span>MyTrait;
|
||
<span class="kw">impl</span><T> MyTrait <span class="kw">for </span>Struct<T> <span class="kw">where </span>T: MyTrait {
|
||
<span class="kw">fn </span>f(<span class="kw-2">&</span><span class="self">self</span>) { ... }
|
||
}
|
||
};</code></pre></div>
|
||
<h6 id="using-the-std-crate"><a href="#using-the-std-crate">Using the <code>std</code> crate</a></h6>
|
||
<p>If you are using <code>quote!()</code> to implement your trait, with the
|
||
<code>proc-macro2/nightly</code> feature, <code>std</code> isn’t considered to be in scope for
|
||
your macro. This means that if you use types from <code>std</code> in your
|
||
procedural macro, you’ll want to explicitly load it with an <code>extern crate std;</code>.</p>
|
||
<h6 id="absolute-paths"><a href="#absolute-paths">Absolute paths</a></h6>
|
||
<p>You should generally avoid using absolute paths in your generated code,
|
||
as they will resolve very differently when using the stable and nightly
|
||
versions of <code>proc-macro2</code>. Instead, load the crates you need to use
|
||
explictly with <code>extern crate</code> and</p>
|
||
<h5 id="trait-bounds"><a href="#trait-bounds">Trait Bounds</a></h5>
|
||
<p>This method will automatically add trait bounds for any type parameters
|
||
which are referenced within the types of non-ignored fields.</p>
|
||
<p>Additional type parameters may be added with the generics syntax after
|
||
the <code>impl</code> keyword.</p>
|
||
<h6 id="type-macro-caveat"><a href="#type-macro-caveat">Type Macro Caveat</a></h6>
|
||
<p>If the method contains any macros in type position, all parameters will
|
||
be considered bound. This is because we cannot determine which type
|
||
parameters are bound by type macros.</p>
|
||
<h5 id="errors"><a href="#errors">Errors</a></h5>
|
||
<p>This function will generate a <code>compile_error!</code> if additional type
|
||
parameters added by <code>impl<..></code> conflict with generic type parameters on
|
||
the original struct.</p>
|
||
<h5 id="panics-6"><a href="#panics-6">Panics</a></h5>
|
||
<p>This function will panic if the input <code>TokenStream</code> is not well-formed.</p>
|
||
<h5 id="example-usage"><a href="#example-usage">Example Usage</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>di: syn::DeriveInput = <span class="macro">syn::parse_quote! </span>{
|
||
<span class="kw">enum </span>A<T, U> {
|
||
B(T),
|
||
C(<span class="prelude-ty">Option</span><U>),
|
||
}
|
||
};
|
||
<span class="kw">let </span><span class="kw-2">mut </span>s = Structure::new(<span class="kw-2">&</span>di);
|
||
|
||
s.filter_variants(|v| v.ast().ident != <span class="string">"B"</span>);
|
||
|
||
<span class="macro">assert_eq!</span>(
|
||
s.gen_impl(<span class="macro">quote! </span>{
|
||
<span class="kw">extern crate </span>krate;
|
||
gen <span class="kw">impl </span>krate::Trait <span class="kw">for </span>@<span class="self">Self </span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where
|
||
</span><span class="prelude-ty">Option</span><U>: krate::Trait,
|
||
U: krate::Trait
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);
|
||
|
||
<span class="comment">// NOTE: You can also add extra generics after the impl
|
||
</span><span class="macro">assert_eq!</span>(
|
||
s.gen_impl(<span class="macro">quote! </span>{
|
||
<span class="kw">extern crate </span>krate;
|
||
gen <span class="kw">impl</span><X: krate::OtherTrait> krate::Trait<X> <span class="kw">for </span>@<span class="self">Self
|
||
</span><span class="kw">where
|
||
</span>X: Send + Sync,
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_X_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><X: krate::OtherTrait, T, U> krate::Trait<X> <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where
|
||
</span>X: Send + Sync,
|
||
<span class="prelude-ty">Option</span><U>: krate::Trait<X>,
|
||
U: krate::Trait<X>
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);
|
||
|
||
<span class="comment">// NOTE: you can generate multiple traits with a single call
|
||
</span><span class="macro">assert_eq!</span>(
|
||
s.gen_impl(<span class="macro">quote! </span>{
|
||
<span class="kw">extern crate </span>krate;
|
||
|
||
gen <span class="kw">impl </span>krate::Trait <span class="kw">for </span>@<span class="self">Self </span>{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
|
||
gen <span class="kw">impl </span>krate::OtherTrait <span class="kw">for </span>@<span class="self">Self </span>{
|
||
<span class="kw">fn </span>b() {}
|
||
}
|
||
}).to_string(),
|
||
<span class="macro">quote!</span>{
|
||
<span class="attr">#[allow(non_upper_case_globals)]
|
||
</span><span class="kw">const </span>_DERIVE_krate_Trait_FOR_A: () = {
|
||
<span class="kw">extern crate </span>krate;
|
||
<span class="kw">impl</span><T, U> krate::Trait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where
|
||
</span><span class="prelude-ty">Option</span><U>: krate::Trait,
|
||
U: krate::Trait
|
||
{
|
||
<span class="kw">fn </span>a() {}
|
||
}
|
||
|
||
<span class="kw">impl</span><T, U> krate::OtherTrait <span class="kw">for </span>A<T, U>
|
||
<span class="kw">where
|
||
</span><span class="prelude-ty">Option</span><U>: krate::OtherTrait,
|
||
U: krate::OtherTrait
|
||
{
|
||
<span class="kw">fn </span>b() {}
|
||
}
|
||
};
|
||
}.to_string()
|
||
);</code></pre></div>
|
||
<p>Use <code>add_bounds</code> to change which bounds are generated.</p>
|
||
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-Clone-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.67.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/clone.rs.html#132-134">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&</a>Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.67.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-Debug-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.67.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.67.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.67.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-Hash-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a><__H: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>>(&self, state: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>__H)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/hash/mod.rs.html#239-241">source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a><H>(data: &<a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>H)<span class="where fmt-newline">where<br> H: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,<br> Self: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.67.0/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CStructure%3C%27a%3E%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-PartialEq%3CStructure%3C%27a%3E%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a>> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
|
||
by <code>==</code>. <a href="https://doc.rust-lang.org/1.67.0/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/cmp.rs.html#229">source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
|
||
sufficient, and should not be overridden without very good reason. <a href="https://doc.rust-lang.org/1.67.0/core/cmp/trait.PartialEq.html#method.ne">Read more</a></div></details></div></details><section id="impl-Eq-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-Eq-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section><section id="impl-StructuralEq-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-StructuralEq-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.StructuralEq.html" title="trait core::marker::StructuralEq">StructuralEq</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section><section id="impl-StructuralPartialEq-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/synstructure/lib.rs.html#938">source</a><a href="#impl-StructuralPartialEq-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Structure%3C%27a%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section><section id="impl-Send-for-Structure%3C%27a%3E" class="impl has-srclink"><a href="#impl-Send-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section><section id="impl-Sync-for-Structure%3C%27a%3E" class="impl has-srclink"><a href="#impl-Sync-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section><section id="impl-Unpin-for-Structure%3C%27a%3E" class="impl has-srclink"><a href="#impl-Unpin-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section><section id="impl-UnwindSafe-for-Structure%3C%27a%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Structure.html" title="struct synstructure::Structure">Structure</a><'a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.67.0/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.67.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.67.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.67.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.67.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> 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.67.0/core/convert/trait.From.html" title="From">From</a><T> for U</code> chooses to do.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/alloc/borrow.rs.html#82">source</a><a href="#impl-ToOwned-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.67.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.67.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/alloc/borrow.rs.html#87">source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.67.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/alloc/borrow.rs.html#91">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/1.67.0/std/primitive.reference.html">&mut </a>T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.67.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#775">source</a><a href="#impl-TryFrom%3CU%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.67.0/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#781">source</a></span><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.67.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Structure%3C%27a%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#760">source</a><a href="#impl-TryInto%3CU%3E-for-Structure%3C%27a%3E" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.67.0/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.67.0/src/core/convert/mod.rs.html#766">source</a></span><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.67.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.67.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="synstructure" data-themes="" data-resource-suffix="" data-rustdoc-version="1.67.0 (fc594f156 2023-01-24)" data-search-js="search-444266647c4dba98.js" data-settings-js="settings-bebeae96e00e4617.js" data-settings-css="settings-af96d9e2fc13e081.css" ></div></body></html> |