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:
parent
bdb39cf723
commit
a869383cda
@ -48,20 +48,15 @@ pub(crate) trait VariantBuilder: Sized {
|
|||||||
/// * `this`: The identifier of the enum
|
/// * `this`: The identifier of the enum
|
||||||
/// * `field`: The field to access
|
/// * `field`: The field to access
|
||||||
fn access_field(&self, this: &Ident, field: VariantField) -> TokenStream {
|
fn access_field(&self, this: &Ident, field: VariantField) -> TokenStream {
|
||||||
match &field.field.data.ident {
|
if let Some(field_ident) = &field.field.data.ident {
|
||||||
Some(field_ident) => {
|
let name = field_ident.to_string();
|
||||||
let name = field_ident.to_string();
|
quote!(#this.field(#name))
|
||||||
quote!(#this.field(#name))
|
} else if let Some(field_index) = field.field.reflection_index {
|
||||||
}
|
quote!(#this.field_at(#field_index))
|
||||||
None => {
|
} else {
|
||||||
if let Some(field_index) = field.field.reflection_index {
|
quote!(::core::compile_error!(
|
||||||
quote!(#this.field_at(#field_index))
|
"internal bevy_reflect error: field should be active"
|
||||||
} else {
|
))
|
||||||
quote!(::core::compile_error!(
|
|
||||||
"internal bevy_reflect error: field should be active"
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user