Skip to content

Commit 3df37e4

Browse files
committed
update derive macro docs
1 parent 3c89a7c commit 3df37e4

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

crates/bevy_derive/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream {
8282

8383
/// Generates an impl of the `AppLabel` trait.
8484
///
85-
/// This works only for unit structs, or enums with only unit variants.
86-
/// You may force a struct or variant to behave as if it were fieldless with `#[app_label(ignore_fields)]`.
85+
/// For unit structs and enums with only unit variants, a cheap implementation can easily be created.
86+
///
87+
/// More complex types must be boxed and identified by their hash
88+
/// - opt in to this by annotating the entire item with `#[app_label(hash)]`.
89+
///
90+
/// Alternatively, you may force a struct or variant to behave as if
91+
/// it were fieldless with `#[app_label(ignore_fields)]`.
8792
#[proc_macro_derive(AppLabel, attributes(app_label))]
8893
pub fn derive_app_label(input: TokenStream) -> TokenStream {
8994
let input = syn::parse_macro_input!(input as syn::DeriveInput);

crates/bevy_ecs/macros/src/lib.rs

+28-8
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,13 @@ pub fn derive_world_query(input: TokenStream) -> TokenStream {
436436

437437
/// Generates an impl of the `SystemLabel` trait.
438438
///
439-
/// This works only for unit structs, or enums with only unit variants.
440-
/// You may force a struct or variant to behave as if it were fieldless with `#[system_label(ignore_fields)]`.
439+
/// For unit structs and enums with only unit variants, a cheap implementation can easily be created.
440+
///
441+
/// More complex types must be boxed and identified by their hash
442+
/// - opt in to this by annotating the entire item with `#[system_label(hash)]`.
443+
///
444+
/// Alternatively, you may force a struct or variant to behave as if
445+
/// it were fieldless with `#[system_label(ignore_fields)]`.
441446
#[proc_macro_derive(SystemLabel, attributes(system_label))]
442447
pub fn derive_system_label(input: TokenStream) -> TokenStream {
443448
let input = parse_macro_input!(input as DeriveInput);
@@ -454,8 +459,13 @@ pub fn derive_system_label(input: TokenStream) -> TokenStream {
454459

455460
/// Generates an impl of the `StageLabel` trait.
456461
///
457-
/// This works only for unit structs, or enums with only unit variants.
458-
/// You may force a struct or variant to behave as if it were fieldless with `#[stage_label(ignore_fields)]`.
462+
/// For unit structs and enums with only unit variants, a cheap implementation can easily be created.
463+
///
464+
/// More complex types must be boxed and identified by their hash
465+
/// - opt in to this by annotating the entire item with `#[stage_label(hash)]`.
466+
///
467+
/// Alternatively, you may force a struct or variant to behave as if
468+
/// it were fieldless with `#[stage_label(ignore_fields)]`.
459469
#[proc_macro_derive(StageLabel, attributes(stage_label))]
460470
pub fn derive_stage_label(input: TokenStream) -> TokenStream {
461471
let input = parse_macro_input!(input as DeriveInput);
@@ -470,8 +480,13 @@ pub fn derive_stage_label(input: TokenStream) -> TokenStream {
470480

471481
/// Generates an impl of the `AmbiguitySetLabel` trait.
472482
///
473-
/// This works only for unit structs, or enums with only unit variants.
474-
/// You may force a struct or variant to behave as if it were fieldless with `#[ambiguity_set_label(ignore_fields)]`.
483+
/// For unit structs and enums with only unit variants, a cheap implementation can easily be created.
484+
///
485+
/// More complex types must be boxed and identified by their hash
486+
/// - opt in to this by annotating the entire item with `#[ambiguity_set_label(hash)]`.
487+
///
488+
/// Alternatively, you may force a struct or variant to behave as if
489+
/// it were fieldless with `#[ambiguity_set_label(ignore_fields)]`.
475490
#[proc_macro_derive(AmbiguitySetLabel, attributes(ambiguity_set_label))]
476491
pub fn derive_ambiguity_set_label(input: TokenStream) -> TokenStream {
477492
let input = parse_macro_input!(input as DeriveInput);
@@ -490,8 +505,13 @@ pub fn derive_ambiguity_set_label(input: TokenStream) -> TokenStream {
490505

491506
/// Generates an impl of the `RunCriteriaLabel` trait.
492507
///
493-
/// This works only for unit structs, or enums with only unit variants.
494-
/// You may force a struct or variant to behave as if it were fieldless with `#[run_criteria_label(ignore_fields)]`.
508+
/// For unit structs and enums with only unit variants, a cheap implementation can easily be created.
509+
///
510+
/// More complex types must be boxed and identified by their hash
511+
/// - opt in to this by annotating the entire item with `#[run_criteria_label(hash)]`.
512+
///
513+
/// Alternatively, you may force a struct or variant to behave as if
514+
/// it were fieldless with `#[run_criteria_label(ignore_fields)]`.
495515
#[proc_macro_derive(RunCriteriaLabel, attributes(run_criteria_label))]
496516
pub fn derive_run_criteria_label(input: TokenStream) -> TokenStream {
497517
let input = parse_macro_input!(input as DeriveInput);

0 commit comments

Comments
 (0)