Skip to content

Commit

Permalink
fix: fix missing brace
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxCWhitehead committed Oct 26, 2024
1 parent 5177eb7 commit 83ec3fb
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions framework_crates/bones_utils/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,30 +219,31 @@ pub fn derive_desync_hash(input: TokenStream) -> TokenStream {
// Helper to get hash invocations of struct fields
let hash_struct_fields = |fields: &StructFields| {
match fields {
venial::StructFields::Tuple(tuple) => tuple
.fields
.iter()
.enumerate()
.map(|(idx, (field, _))| {
let ty = &field.ty;
quote! {<#ty as #desync_hash_module::DesyncHash>::hash(&self.#idx, hasher);}
})
.collect::<Vec<_>>(),
venial::StructFields::Named(named) => named
.fields
.iter()
.filter_map(|(field, _)| {
let name = &field.name;
let ty = &field.ty;
if !field.attributes.iter().any(|attr| {
attr.path[0].to_string() == "desync_exclude"
}) {
return Some(quote! {<#ty as #desync_hash_module::DesyncHash>::hash(&self.#name, hasher);})
}
None
})
.collect::<Vec<_>>(),
venial::StructFields::Unit => vec![],
venial::StructFields::Tuple(tuple) => tuple
.fields
.iter()
.enumerate()
.map(|(idx, (field, _))| {
let ty = &field.ty;
quote! {<#ty as #desync_hash_module::DesyncHash>::hash(&self.#idx, hasher);}
})
.collect::<Vec<_>>(),
venial::StructFields::Named(named) => named
.fields
.iter()
.filter_map(|(field, _)| {
let name = &field.name;
let ty = &field.ty;
if !field.attributes.iter().any(|attr| {
attr.path[0].to_string() == "desync_exclude"
}) {
return Some(quote! {<#ty as #desync_hash_module::DesyncHash>::hash(&self.#name, hasher);})
}
None
})
.collect::<Vec<_>>(),
venial::StructFields::Unit => vec![],
}
};

// Get fields of enum variant
Expand Down

0 comments on commit 83ec3fb

Please sign in to comment.