bevy/crates
robtfm 7ff61a8dc9
derive asset for enums (#10410)
# 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>
2023-11-21 01:06:55 +00:00
..
bevy_a11y Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_animation Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_app Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_asset derive asset for enums (#10410) 2023-11-21 01:06:55 +00:00
bevy_audio Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_core Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_core_pipeline Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_diagnostic Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_dylib Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_dynamic_plugin Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_ecs Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_ecs_compile_fail_tests Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_encase_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gilrs Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gizmos Move Circle Gizmos to Their Own File (#10631) 2023-11-20 09:47:50 +00:00
bevy_gltf Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_hierarchy Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_input Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_internal Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_log Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_macro_utils Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_macros_compile_fail_tests Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_math Add winding order for Triangle2d (#10620) 2023-11-20 09:47:05 +00:00
bevy_mikktspace Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_pbr Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_ptr Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_reflect Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_reflect_compile_fail_tests Improve TypeUuid's derive macro error messages (#9315) 2023-10-02 12:42:01 +00:00
bevy_render Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_scene Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_sprite Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_tasks Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_text Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_time Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_transform Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_ui Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_utils Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_window Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_winit Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00