Skip to content

Commit b5f5c66

Browse files
committed
Rename to_/from_ methods to avoid Clippy warnings on Nightly
1 parent 42a6e76 commit b5f5c66

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

gdnative-derive/src/variant/from.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) fn expand_from_variant(derive_data: DeriveData) -> Result<TokenStream
2222

2323
let return_expr = match repr {
2424
Repr::Struct(var_repr) => {
25-
let from_variant = var_repr.from_variant(&input_ident, &quote! { #ident })?;
25+
let from_variant = var_repr.make_from_variant_expr(&input_ident, &quote! { #ident })?;
2626
quote! {
2727
{
2828
#from_variant
@@ -54,7 +54,8 @@ pub(crate) fn expand_from_variant(derive_data: DeriveData) -> Result<TokenStream
5454
let var_from_variants = variants
5555
.iter()
5656
.map(|(var_ident, var_repr)| {
57-
var_repr.from_variant(&var_input_ident, &quote! { #ident::#var_ident })
57+
var_repr
58+
.make_from_variant_expr(&var_input_ident, &quote! { #ident::#var_ident })
5859
})
5960
.collect::<Result<Vec<_>, _>>()?;
6061

gdnative-derive/src/variant/repr.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl VariantRepr {
101101
}
102102
}
103103

104-
pub(crate) fn to_variant(
104+
pub(crate) fn make_to_variant_expr(
105105
&self,
106106
trait_kind: ToVariantTrait,
107107
) -> Result<TokenStream2, syn::Error> {
@@ -119,13 +119,13 @@ impl VariantRepr {
119119
"cannot skip the only field in a tuple",
120120
));
121121
}
122-
field.to_variant(trait_kind)
122+
field.make_to_variant_expr(trait_kind)
123123
} else {
124124
let exprs = fields.iter().filter_map(|f| {
125125
if f.attr.skip_to_variant {
126126
None
127127
} else {
128-
Some(f.to_variant(trait_kind))
128+
Some(f.make_to_variant_expr(trait_kind))
129129
}
130130
});
131131

@@ -150,7 +150,7 @@ impl VariantRepr {
150150
let name_string_literals =
151151
name_strings.iter().map(|string| Literal::string(string));
152152

153-
let exprs = fields.iter().map(|f| f.to_variant(trait_kind));
153+
let exprs = fields.iter().map(|f| f.make_to_variant_expr(trait_kind));
154154

155155
quote! {
156156
{
@@ -170,7 +170,7 @@ impl VariantRepr {
170170
Ok(tokens)
171171
}
172172

173-
pub(crate) fn from_variant(
173+
pub(crate) fn make_from_variant_expr(
174174
&self,
175175
variant: &Ident,
176176
ctor: &TokenStream2,
@@ -199,7 +199,7 @@ impl VariantRepr {
199199
"cannot skip the only field in a tuple",
200200
));
201201
}
202-
let expr = field.from_variant(&quote!(#variant));
202+
let expr = field.make_from_variant_expr(&quote!(#variant));
203203
quote! {
204204
{
205205
#expr.map(#ctor)
@@ -224,7 +224,7 @@ impl VariantRepr {
224224
let expr_variant = &quote!(&__array.get(__index));
225225
let non_skipped_exprs = non_skipped_fields
226226
.iter()
227-
.map(|f| f.from_variant(expr_variant));
227+
.map(|f| f.make_from_variant_expr(expr_variant));
228228

229229
quote! {
230230
{
@@ -283,7 +283,7 @@ impl VariantRepr {
283283
let expr_variant = &quote!(&__dict.get_or_nil(&__key));
284284
let exprs = non_skipped_fields
285285
.iter()
286-
.map(|f| f.from_variant(expr_variant));
286+
.map(|f| f.make_from_variant_expr(expr_variant));
287287

288288
quote! {
289289
{
@@ -317,7 +317,7 @@ impl VariantRepr {
317317
}
318318

319319
impl Field {
320-
fn to_variant(&self, trait_kind: ToVariantTrait) -> TokenStream2 {
320+
fn make_to_variant_expr(&self, trait_kind: ToVariantTrait) -> TokenStream2 {
321321
let Field { ident, attr, .. } = self;
322322
if let Some(to_variant_with) = &attr.to_variant_with {
323323
quote!(#to_variant_with(#ident))
@@ -327,7 +327,7 @@ impl Field {
327327
}
328328
}
329329

330-
fn from_variant(&self, variant: &TokenStream2) -> TokenStream2 {
330+
fn make_from_variant_expr(&self, variant: &TokenStream2) -> TokenStream2 {
331331
if let Some(from_variant_with) = &self.attr.from_variant_with {
332332
quote!(#from_variant_with(#variant))
333333
} else {

gdnative-derive/src/variant/to.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) fn expand_to_variant(
2525
let return_expr = match repr {
2626
Repr::Struct(var_repr) => {
2727
let destructure_pattern = var_repr.destructure_pattern();
28-
let to_variant = var_repr.to_variant(trait_kind)?;
28+
let to_variant = var_repr.make_to_variant_expr(trait_kind)?;
2929
quote! {
3030
{
3131
let #ident #destructure_pattern = self;
@@ -43,7 +43,7 @@ pub(crate) fn expand_to_variant(
4343
.iter()
4444
.map(|(var_ident, var_repr)| {
4545
let destructure_pattern = var_repr.destructure_pattern();
46-
let to_variant = var_repr.to_variant(trait_kind)?;
46+
let to_variant = var_repr.make_to_variant_expr(trait_kind)?;
4747
let var_ident_string = format!("{}", var_ident);
4848
let var_ident_string_literal = Literal::string(&var_ident_string);
4949
let tokens = quote! {

0 commit comments

Comments
 (0)