-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# 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>
- Loading branch information
Showing
2 changed files
with
93 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters