mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Modify Derive to allow unit structs for RenderResources. (#1089)
This commit is contained in:
parent
acc29ec719
commit
cbc0fe1416
2 changed files with 9 additions and 2 deletions
|
@ -2,7 +2,8 @@ use crate::modules::{get_modules, get_path};
|
|||
use proc_macro::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
use syn::{
|
||||
parse::ParseStream, parse_macro_input, Data, DataStruct, DeriveInput, Field, Fields, Path,
|
||||
parse::ParseStream, parse_macro_input, punctuated::Punctuated, Data, DataStruct, DeriveInput,
|
||||
Field, Fields, Path,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -72,11 +73,17 @@ pub fn derive_render_resources(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
})
|
||||
} else {
|
||||
let empty = Punctuated::new();
|
||||
|
||||
let fields = match &ast.data {
|
||||
Data::Struct(DataStruct {
|
||||
fields: Fields::Named(fields),
|
||||
..
|
||||
}) => &fields.named,
|
||||
Data::Struct(DataStruct {
|
||||
fields: Fields::Unit,
|
||||
..
|
||||
}) => &empty,
|
||||
_ => panic!("Expected a struct with named fields."),
|
||||
};
|
||||
let field_attributes = fields
|
||||
|
|
|
@ -21,7 +21,7 @@ fn main() {
|
|||
|
||||
#[derive(RenderResources, Default, TypeUuid)]
|
||||
#[uuid = "0320b9b8-b3a3-4baa-8bfa-c94008177b17"]
|
||||
struct MyMaterialWithVertexColorSupport {}
|
||||
struct MyMaterialWithVertexColorSupport;
|
||||
|
||||
const VERTEX_SHADER: &str = r#"
|
||||
#version 450
|
||||
|
|
Loading…
Reference in a new issue