mirror of
https://github.com/bevyengine/bevy
synced 2024-12-22 19:13:08 +00:00
7ff61a8dc9
# Objective allow deriving `Asset` for enums, and for tuple structs. ## Solution add to the proc macro, generating visitor calls to the variant's data (if required). supports unnamed or named field variants, and struct variants when the struct also derives `Asset`: ```rust #[derive(Asset, TypePath)] pub enum MyAssetEnum { Unnamed ( #[dependency] Handle<Image> ), Named { #[dependency] array_handle: Handle<Image>, #[dependency] atlas_handles: Vec<Handle<Image>>, }, StructStyle( #[dependency] VariantStruct ), Empty, } #[derive(Asset, TypePath)] pub struct VariantStruct { // ... } ``` also extend the struct implementation to support tuple structs: ```rust #[derive(Asset, TypePath)] pub struct MyImageNewtype( #[dependency] Handle<Image> ); ```` --------- Co-authored-by: Nicola Papale <nico@nicopap.ch> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |