Skip to content

Commit

Permalink
deploy: a427010
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed Feb 18, 2024
1 parent 95d407e commit 8434e01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@
<a href="#25" id="25">25</a>
<a href="#26" id="26">26</a>
<a href="#27" id="27">27</a>
<a href="#28" id="28">28</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>quote::{format_ident, quote};
<span class="kw">use </span>syn::GenericArgument;

<span class="attr">#[derive(Debug)]
</span><span class="kw">pub struct </span>TypeStateItem {
field_name: String,
generic_param: GenericArgument,
generic_parameter: GenericArgument,
}

<span class="kw">impl </span>TypeStateItem {
<span class="kw">pub fn </span>new(index: usize, field_name: String) -&gt; <span class="self">Self </span>{
<span class="kw">let </span>identifier = <span class="macro">format_ident!</span>(<span class="string">"T{}"</span>, index);

<span class="self">Self </span>{
generic_param: {
<span class="kw">let </span>ident = <span class="macro">format_ident!</span>(<span class="string">"T{}"</span>, index);
syn::parse2(<span class="macro">quote!</span>(#ident)).expect(<span class="string">"Ident is a valid GenericArgument"</span>)
},
generic_parameter: syn::parse2(<span class="macro">quote!</span>(#identifier)).expect(<span class="string">"valid GenericArgument"</span>),
field_name,
}
}
Expand All @@ -51,8 +49,8 @@
<span class="kw-2">&amp;</span><span class="self">self</span>.field_name
}

<span class="kw">pub fn </span>generic_param(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>GenericArgument {
<span class="kw-2">&amp;</span><span class="self">self</span>.generic_param
<span class="kw">pub fn </span>generic_parameter(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>GenericArgument {
<span class="kw-2">&amp;</span><span class="self">self</span>.generic_parameter
}
}
</code></pre></div></section></main></body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}

<span class="kw">pub fn </span>parameters(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw">impl </span>Iterator&lt;Item = <span class="kw-2">&amp;</span>GenericArgument&gt; {
<span class="self">self</span>.items.iter().map(|item| item.generic_param())
<span class="self">self</span>.items.iter().map(|item| item.generic_parameter())
}

<span class="kw">pub fn </span>parameters_without&lt;<span class="lifetime">'a</span>&gt;(
Expand All @@ -92,7 +92,7 @@
<span class="self">self</span>.items
.iter()
.filter(<span class="kw">move </span>|item| item.field_name() != field_name)
.map(|item| item.generic_param())
.map(|item| item.generic_parameter())
}

<span class="kw">pub fn </span>arguments_set&lt;<span class="lifetime">'a</span>&gt;(
Expand All @@ -104,7 +104,7 @@
<span class="kw">if </span>item.field_name() == field_name {
<span class="self">self</span>.set_argument(set)
} <span class="kw">else </span>{
item.generic_param()
item.generic_parameter()
}
})
}
Expand Down

0 comments on commit 8434e01

Please sign in to comment.