Minor code readability improvement in enum_utility.access_field (#19961)

Small cleanup copied from https://github.com/bevyengine/bevy/pull/16250
This commit is contained in:
theotherphil 2025-07-05 15:40:23 +01:00 committed by GitHub
parent bdb39cf723
commit a869383cda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,13 +48,10 @@ pub(crate) trait VariantBuilder: Sized {
/// * `this`: The identifier of the enum
/// * `field`: The field to access
fn access_field(&self, this: &Ident, field: VariantField) -> TokenStream {
match &field.field.data.ident {
Some(field_ident) => {
if let Some(field_ident) = &field.field.data.ident {
let name = field_ident.to_string();
quote!(#this.field(#name))
}
None => {
if let Some(field_index) = field.field.reflection_index {
} else if let Some(field_index) = field.field.reflection_index {
quote!(#this.field_at(#field_index))
} else {
quote!(::core::compile_error!(
@ -62,8 +59,6 @@ pub(crate) trait VariantBuilder: Sized {
))
}
}
}
}
/// Returns a token stream that unwraps a field of a variant as a `&dyn Reflect`
/// (from an `Option<dyn Reflect>`).