diff --git a/lyra-ecs/src/bundle.rs b/lyra-ecs/src/bundle.rs index 31d1952..7e8274a 100644 --- a/lyra-ecs/src/bundle.rs +++ b/lyra-ecs/src/bundle.rs @@ -17,6 +17,24 @@ pub trait Bundle { fn is_dynamic(&self) -> bool; } +impl Bundle for () { + fn type_ids(&self) -> Vec { + vec![DynTypeId::of::<()>()] + } + + fn info(&self) -> Vec { + vec![ComponentInfo::new::<()>()] + } + + fn take(self, mut f: impl FnMut(NonNull, DynTypeId, usize)) { + f(NonNull::from(&self).cast(), DynTypeId::of::<()>(), size_of::<()>()); + } + + fn is_dynamic(&self) -> bool { + false + } +} + impl Bundle for C { fn type_ids(&self) -> Vec { vec![DynTypeId::of::()] diff --git a/lyra-reflect/lyra-reflect-derive/src/enum_derive.rs b/lyra-reflect/lyra-reflect-derive/src/enum_derive.rs index 306de32..1f97862 100644 --- a/lyra-reflect/lyra-reflect-derive/src/enum_derive.rs +++ b/lyra-reflect/lyra-reflect-derive/src/enum_derive.rs @@ -32,7 +32,7 @@ impl From<&Variant> for VariantType { /// Generates the following different outputs: /// -/// ```compile_fail +/// ```nobuild /// // for struct variants /// TestEnum::Error { msg, code } /// @@ -98,7 +98,7 @@ fn gen_variant_if(enum_id: &proc_macro2::Ident, variant: &Variant, if_body: proc /// Generates the following: /// -/// ```compile_fail +/// ```nobuild /// /// generated one field here /// if name == "msg" { /// return Some(msg); @@ -129,7 +129,7 @@ fn gen_if_field_names(variant: &Variant) -> proc_macro2::TokenStream { /// Generates the following rust code: /// -/// ```compile_fail +/// ```nobuild /// match name { /// "msg" | "code" => true, /// _ => false, @@ -153,7 +153,7 @@ fn gen_match_names(variant: &Variant) -> proc_macro2::TokenStream { /// Generates the following: /// -/// ```compile_fail +/// ```nobuild /// /// generated one field here /// if idx == 0 { /// return Some(a); @@ -190,7 +190,7 @@ fn gen_if_field_indices(variant: &Variant) -> proc_macro2::TokenStream { /// Generates the following: /// -/// ```compile_fail +/// ```nobuild /// /// generated one field here /// if idx == 0 { /// return Some("a"); @@ -226,7 +226,7 @@ fn gen_if_field_indices_names(variant: &Variant) -> proc_macro2::TokenStream { } /// Generates the following: -/// ```compile_fail +/// ```nobuild /// /// when `by_index` is false: /// /// if let TestEnum::Error{ msg, code} = self { @@ -300,7 +300,7 @@ fn gen_enum_if_stmts(enum_id: &proc_macro2::Ident, data: &DataEnum, by_index: bo /// Generates the following rust code: /// -/// ```compile_fail +/// ```nobuild /// if let TestEnum::Error { msg, code } = self { /// return match name { /// // expands for continuing struct fields @@ -331,7 +331,7 @@ fn gen_enum_has_field(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc_mac /// Generates the following code: /// -/// ```compile_fail +/// ```nobuild /// match self { /// TestEnum::Start => 0, /// TestEnum::Middle(a, b) => 2, @@ -358,7 +358,7 @@ fn gen_enum_fields_len(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc_ma /// Generates the following code: /// -/// ```compile_fail +/// ```nobuild /// if let TestEnum::Error { msg, code } = self { /// if idx == 0 { /// return Some("msg"); @@ -389,7 +389,7 @@ fn gen_enum_field_name_at(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc } /// Generates the following code: -/// ```compile_fail +/// ```nobuild /// match self { /// TestEnum::Start => 0, /// TestEnum::Middle(a, b) => 1, @@ -427,7 +427,7 @@ fn gen_enum_variant_name(enum_id: &proc_macro2::Ident, data: &DataEnum, gen_inde /// Generates a match statement that returns the types of the variants of the enum. /// /// Example: -/// ```compile_fail +/// ```nobuild /// match self { /// TestEnum::Start => EnumType::Unit, /// TestEnum::Middle(a, b) => EnumType::Tuple, diff --git a/lyra-reflect/lyra-reflect-derive/src/struct_derive.rs b/lyra-reflect/lyra-reflect-derive/src/struct_derive.rs index 6bea7a8..b8dad88 100644 --- a/lyra-reflect/lyra-reflect-derive/src/struct_derive.rs +++ b/lyra-reflect/lyra-reflect-derive/src/struct_derive.rs @@ -28,7 +28,7 @@ impl StructType { /// contains a borrow (mutable borrow if `is_mut` is true) to the matching struct field. /// /// Example: -/// ```compile_fail +/// ```nobuild /// // when `is_mut` = false /// match name { /// "x" => Some(&self.x), @@ -85,7 +85,7 @@ fn gen_struct_field_match(data: &DataStruct, is_mut: bool) -> proc_macro2::Token /// with the provided `val`. /// /// Example: -/// ```compile_fail +/// ```nobuild /// match name { /// "x" => self.x = any_val.downcast_ref::() /// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name())) @@ -140,7 +140,7 @@ fn gen_struct_set_field_match(data: &DataStruct) -> proc_macro2::TokenStream { /// the type of the field. /// /// Example: -/// ```compile_fail +/// ```nobuild /// match name { /// "x" => Some("f32"), /// "y" => Some("f32"), @@ -177,7 +177,7 @@ fn gen_struct_field_name_match(data: &DataStruct) -> proc_macro2::TokenStream { /// with the provided `val`. /// /// Example: -/// ```compile_fail +/// ```nobuild /// match name { /// 0 => self.x = any_val.downcast_ref::() /// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name())) @@ -243,7 +243,7 @@ fn gen_struct_set_field_match_idx(data: &DataStruct) -> proc_macro2::TokenStream /// type of the field. /// /// Example: -/// ```compile_fail +/// ```nobuild /// match name { /// 0 => Some("f32"), /// 1 => Some("f32"), @@ -274,7 +274,7 @@ fn gen_struct_field_name_match_idx(data: &DataStruct) -> proc_macro2::TokenStrea /// to the matching struct field. /// /// Example: -/// ```compile_fail +/// ```nobuild /// // when `is_mut` = false /// match idx { /// 0 => Some(&self.x), @@ -335,7 +335,7 @@ fn gen_struct_field_match_idx(data: &DataStruct, is_mut: bool) -> proc_macro2::T /// and returns an Option that contains the name of the field. /// /// Example: -/// ```compile_fail +/// ```nobuild /// match idx { /// 0 => Some("x"), /// 1 => Some("y"), diff --git a/shell.nix b/shell.nix index 98db997..f0620b7 100755 --- a/shell.nix +++ b/shell.nix @@ -19,6 +19,7 @@ in extensions = [ "rust-src" "rust-analysis" + "miri-preview" ]; }) ];