ecs, reflect: implement Bundle for (), use `nobuild` instead of `compile_fail` for reflect rustdocs
This commit is contained in:
parent
e5018c8258
commit
a2aac25249
|
@ -17,6 +17,24 @@ pub trait Bundle {
|
|||
fn is_dynamic(&self) -> bool;
|
||||
}
|
||||
|
||||
impl Bundle for () {
|
||||
fn type_ids(&self) -> Vec<DynTypeId> {
|
||||
vec![DynTypeId::of::<()>()]
|
||||
}
|
||||
|
||||
fn info(&self) -> Vec<ComponentInfo> {
|
||||
vec![ComponentInfo::new::<()>()]
|
||||
}
|
||||
|
||||
fn take(self, mut f: impl FnMut(NonNull<u8>, DynTypeId, usize)) {
|
||||
f(NonNull::from(&self).cast(), DynTypeId::of::<()>(), size_of::<()>());
|
||||
}
|
||||
|
||||
fn is_dynamic(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Component> Bundle for C {
|
||||
fn type_ids(&self) -> Vec<DynTypeId> {
|
||||
vec![DynTypeId::of::<C>()]
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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::<f32>()
|
||||
/// .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::<f32>()
|
||||
/// .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"),
|
||||
|
|
Loading…
Reference in New Issue