Skip to content

Commit

Permalink
Rename the phantom generics field for style
Browse files Browse the repository at this point in the history
`_TypedBuilder__phantomGenerics_` → `__typed_builder_phantom_generics`.
Snake case instead of a mix of PascalCase and camelCase (the latter of
which especially is entirely unprecedented in Rust).

There’s much precedent in the Rust ecosystem for a leading double
underscore for things like this. (Frankly I’d call even the
“typed_builder” part unnecessary, but it’s fairly harmless.)
  • Loading branch information
chris-morgan committed Mar 19, 2019
1 parent 31b17cb commit e62ffe0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/struct_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ impl<'a> StructInfo<'a> {
let phantom_generic_fields = if skip_phantom_generics {
quote!()
} else {
quote!(_TypedBuilder__phantomGenerics_: (#( #phantom_generics ),*),)
quote!(__typed_builder_phantom_generics: (#( #phantom_generics ),*),)
};
let init_phantom_generics = if skip_phantom_generics {
quote!()
} else {
quote!(_TypedBuilder__phantomGenerics_: #core::default::Default::default(),)
quote!(__typed_builder_phantom_generics: #core::default::Default::default(),)
};
Ok(quote! {
extern crate core as #core;
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<'a> StructInfo<'a> {
let phantom_generics = if self.generics.params.is_empty() {
quote!()
} else {
quote!(_TypedBuilder__phantomGenerics_: self._TypedBuilder__phantomGenerics_,)
quote!(__typed_builder_phantom_generics: self.__typed_builder_phantom_generics,)
};
Ok(quote! {
#[allow(dead_code, non_camel_case_types, missing_docs)]
Expand Down

0 comments on commit e62ffe0

Please sign in to comment.