### Example struct with children attribute Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Superclass.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example of a struct using `#[derive(Superclass)]` with the `#[superclass(children(Cow, Pig))]` attribute to generate subclass enums. ```rust #[repr(C)] #[derive(Superclass)] #[superclass(children(Cow, Pig))] pub struct Animal { _vftable: usize, } ``` -------------------------------- ### Macro usage example: for_all_subclasses on pub impl Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.for_all_subclasses.html Shows the macro applied to a public trait impl for `Subclass`. The impl must include functions and have a visibility modifier; otherwise the generated trait will be private. The macro defines a trait with the given name and implements it for all subclasses of the superclass, allowing superclass methods to be called on any subclass. ```rust #[for_all_subclasses] pub impl ChrInsExt for Subclass { fn apply_speffect(&mut self, sp_effect: i32, dont_sync: bool) { let rva = Program::current() .rva_to_va(rva::get().chr_ins_apply_speffect) .unwrap(); let call = unsafe { transmute:: u64>(rva) }; call(self, sp_effect, dont_sync); } fn remove_speffect(&mut self, sp_effect: i32) { let rva = Program::current() .rva_to_va(rva::get().chr_ins_remove_speffect) .unwrap(); let call = unsafe { transmute:: u64>(rva) }; call(self, sp_effect); } } ``` -------------------------------- ### Derive Researching macro with superclass attribute Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Researching.html?search= Use this derive macro on a struct to automatically implement fromsoftware_shared::Researching, making all unk fields available through Researching::unknown_fields. The example shows the available #[superclass] attribute. ```rust #[derive(Researching)] { // Attributes available to this derive: #[superclass] } ``` -------------------------------- ### Generated enums for EquipParam Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html Each trait generates two enums, one immutable and one mutable, with variants for each parameter type. The example shows the enums for the `EquipParam` trait. ```rust pub enum EquipParamStruct<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a EQUIP_PARAM_WEAPON_ST), } impl EquipParamStruct<'_> { pub fn as_dyn(&self) -> &dyn EquipParam; } pub enum EquipParamStructMut<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a mut EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a mut EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a mut EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a mut EQUIP_PARAM_WEAPON_ST), } impl EquipParamStructMut<'_> { pub fn as_dyn(&mut self) -> &mut dyn EquipParam; } ``` -------------------------------- ### derive(Subclass) Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Subclass.html Derive macro that implements the fromsoftware_shared::Subclass trait for a struct. It uses a standard RVA struct to get the VMT address and determines the superclass from the first field or via the #[subclass(base = ...)] attribute. ```APIDOC ## Derive Macro Subclass ### Description A derive macro for `fromsoftware_shared::Subclass`. It adds an implementation of `Subclass` that gets its VMT address from a standard RVA struct. The macro assumes the crate contains a `crate::rva` module with a `get()` function, and the return value has a public field named as the snake-case version of the struct's name followed by `_vmt`. ### Usage ```rust #[derive(Subclass)] { // Attributes available to this derive: #[subclass] } ``` ### Attributes - `#[subclass(base = SuperclassType)]` - Explicitly choose one or more superclasses. By default, the type of the first field is used as the superclass. ### Additional Implementations - `AsRef` - `AsMut` - `TryFrom<&SuperclassType>` - `Deref` and `DerefMut` (only for the first superclass if multiple are declared) ### Safety This derive macro does not add any additional safety guarantees beyond a manual implementation. The `fromsoftware_shared::Subclass` trait is unsafe, and users must read the `Subclass` documentation carefully to understand the requirements. ``` -------------------------------- ### Derive Subclass macro for fromsoftware_shared::Subclass Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Subclass.html?search= Use this derive macro to implement the `fromsoftware_shared::Subclass` trait for a struct. The macro assumes a `crate::rva` module with a `get()` function returning a value with a public field named as the snake_case struct name plus `_vmt`. By default, the first field's type is the superclass; override with `#[subclass(base = SuperclassType)]`. It also implements `AsRef`, `AsMut`, `TryFrom`, `Deref`, and `DerefMut` for the superclass, with `Deref` and `DerefMut` only for the first superclass if multiple are declared. ```rust #[derive(Subclass)] { // Attributes available to this derive: #[subclass] } ``` -------------------------------- ### Derive macro attribute syntax Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Superclass.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows the basic syntax for using the `#[derive(Superclass)]` attribute. The `#[superclass]` attribute is available for this derive. ```rust #[derive(Superclass)] { // Attributes available to this derive: #[superclass] } ``` -------------------------------- ### Basic usage of #[multi_param] Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html Annotates a trait with `#[multi_param]` and lists the structs for which implementations are generated. The trait must contain a `fields!` macro with named fields. ```rust #[multi_param(EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST)] pub trait EquipParamPassive: EquipParam { fields! { sfx_variation_id: i32, ref_category: u8, sp_effect_category: u8, shop_lv: i16, } } ``` -------------------------------- ### singleton attribute macro usage Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.singleton.html?search= Annotates a struct as a Dantelion2 singleton. Only guaranteed to work with `fromsoftware_shared::singleton::get_instance`; other functionality is not guaranteed. ```rust #[singleton] ``` -------------------------------- ### multi_param Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html Annotates a trait to automatically generate getters and setters that forward to methods of the same name in various structs. It takes struct names as arguments and generates implementations for each field. ```APIDOC ## Attribute Macro `multi_param` ### Description Annotates a trait to automatically generate getters and setters that forward to methods of the same name in various structs. This is used to create traits that encapsulate state shared across multiple parameter definitions. ### Usage ```rust #[multi_param(EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST)] pub trait EquipParamPassive: EquipParam { fields! { sfx_variation_id: i32, ref_category: u8, sp_effect_category: u8, shop_lv: i16, } } ``` ### Parameters - **struct names** (ident) - Required - Names of structs for which to generate implementations. ### Field Attributes #### `rename()` Renames the field this targets for a particular struct. Syntax: `#[multi_param(rename(param = ..., name = ...))]`. The `param` must exactly match one of the structs passed to the outer annotation, and `name` must be a valid identifier. Example: ```rust #[multi_param( EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST, EQUIP_PARAM_PROTECTOR_ST, EQUIP_PARAM_WEAPON_ST )] pub trait EquipParam { fields! { weight: f32, basic_price: i32, sell_value: i32, sort_id: i32, vagrant_item_lot_id: i32, #[multi_param( rename(param = EQUIP_PARAM_PROTECTOR_ST, name = "vagrant_bonusene_drop_item_lot_id"), rename(param = EQUIP_PARAM_WEAPON_ST, name = "vagrant_bonusene_drop_item_lot_id"), )] vagrant_bonus_ene_drop_item_lot_id: i32; vagrant_item_ene_drop_item_lot_id: i32, } } ``` ### Generated Enums Each trait also generates two enums, one mutable and one immutable, which can be used in contexts where it's relevant which param type in particular you have. These enums have a variant for each defined parameter type. Example: ```rust pub enum EquipParamStruct<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a EQUIP_PARAM_WEAPON_ST), } impl EquipParamStruct<'_> { pub fn as_dyn(&self) -> &dyn EquipParam; } pub enum EquipParamStructMut<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a mut EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a mut EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a mut EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a mut EQUIP_PARAM_WEAPON_ST), } impl EquipParamStructMut<'_> { pub fn as_dyn(&mut self) -> &mut dyn EquipParam; } ``` You can access these using the `as_enum()` and `as_enum_mut()` methods. ``` -------------------------------- ### Field rename with multi_param Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to use the rename() field attribute to map a field to different names in specific structs. The struct must match one of the structs passed to the outer annotation. ```rust #[multi_param( EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST, EQUIP_PARAM_PROTECTOR_ST, EQUIP_PARAM_WEAPON_ST )] pub trait EquipParam { fields! { weight: f32, basic_price: i32, sell_value: i32, sort_id: i32, vagrant_item_lot_id: i32, #[multi_param( rename(param = EQUIP_PARAM_PROTECTOR_ST, name = "vagrant_bonusene_drop_item_lot_id"), rename(param = EQUIP_PARAM_WEAPON_ST, name = "vagrant_bonusene_drop_item_lot_id"), )] vagrant_bonus_ene_drop_item_lot_id: i32; vagrant_item_ene_drop_item_lot_id: i32, } } ``` -------------------------------- ### Annotate a trait with #[multi_param] Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html?search=u32+-%3E+bool Annotates a trait to automatically generate getters and setters that forward to methods of the same name in various structs. Use it on a trait that contains a `fields!` macro, using the same named field syntax as a struct. ```rust #[multi_param] ``` -------------------------------- ### Generate subclass enums with #[superclass(children(...))] Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Superclass.html Shows how to use the #[superclass(children(...))] attribute to generate immutable and mutable subclass enums. The first block is the input struct; the second block is the generated code, including enums and From implementations. ```rust #[repr(C)] #[derive(Superclass)] #[superclass(children(Cow, Pig))] pub struct Animal { _vftable: usize, } ``` ```rust pub enum AnimalSubclasses<'sub> { Cow(&'sub Cow), Pig(&'sub Pig), Animal(&'sub Animal), } pub enum AnimalSubclassesMut<'sub> { Cow(&'sub mut Cow), Pig(&'sub mut Pig), Animal(&'sub mut Animal), } impl AnimalSubclasses<'_> { pub fn superclass(&self) -> &Animal; } impl AnimalSubclassesMut<'_> { pub fn superclass(&self) -> &Animal; pub fn superclass_mut(&mut self) -> &mut Animal; } impl<'sub> From> for AnimalSubclasses<'sub> {} impl<'sub> From<&'sub T> for AnimalSubclasses<'sub> where T: Subclass {} impl<'sub> From<&'sub mut T> for AnimalSubclassesMut<'sub> where T: Subclass {} ``` -------------------------------- ### derive(Superclass) Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Superclass.html?search=std%3A%3Avec Derive macro that implements `fromsoftware_shared::Superclass` for a struct. It obtains the VMT address from a standard RVA struct via `crate::rva::get()`. Optionally, with `#[superclass(children(...))]`, it generates immutable and mutable subclass enums. ```APIDOC ## Derive Macro `Superclass` ### Description A derive macro for `fromsoftware_shared::Superclass`. It adds an implementation of `Superclass` that gets its VMT address from a standard RVA struct. The macro assumes the crate using it contains a `crate::rva` module that exposes a `get()` function, and that the return value has a public field whose name is a snake-case version of the struct's name followed by `_vmt`. ### Usage Apply `#[derive(Superclass)]` to a struct. Optionally, add `#[superclass(children(ChildName1, ChildName2))]` to generate subclass enums. ### Attributes - `#[superclass]` - Marks the derive macro. - `#[superclass(children(ChildName1, ChildName2))]` - Generates two enums: `StructNameSubclasses` and `StructNameSubclassesMut`, along with their implementations. ### Example ```rust #[repr(C)] #[derive(Superclass)] #[superclass(children(Cow, Pig))] pub struct Animal { _vftable: usize, } ``` ### Generated Code For the example above, the macro generates: ```rust pub enum AnimalSubclasses<'sub> { Cow(&'sub Cow), Pig(&'sub Pig), Animal(&'sub Animal), } pub enum AnimalSubclassesMut<'sub> { Cow(&'sub mut Cow), Pig(&'sub mut Pig), Animal(&'sub mut Animal), } impl AnimalSubclasses<'_> { pub fn superclass(&self) -> &Animal; } impl AnimalSubclassesMut<'_> { pub fn superclass(&self) -> &Animal; pub fn superclass_mut(&mut self) -> &mut Animal; } impl<'sub> From> for AnimalSubclasses<'sub> {} impl<'sub> From<&'sub T> for AnimalSubclasses<'sub> where T: Subclass {} impl<'sub> From<&'sub mut T> for AnimalSubclassesMut<'sub> where T: Subclass {} ``` ### Safety The `fromsoftware_shared::Superclass` trait is unsafe. This derive macro does not add any additional safety guarantees beyond a manual implementation. Users must read the `Superclass` documentation carefully to understand the safety requirements. ``` -------------------------------- ### Generated enums for parameter types Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows the enums generated by multi_param for the EquipParam trait, including immutable and mutable variants with as_dyn methods. ```rust pub enum EquipParamStruct<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a EQUIP_PARAM_WEAPON_ST), } impl EquipParamStruct<'_> { pub fn as_dyn(&self) -> &dyn EquipParam; } pub enum EquipParamStructMut<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a mut EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a mut EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a mut EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a mut EQUIP_PARAM_WEAPON_ST), } impl EquipParamStructMut<'_> { pub fn as_dyn(&mut self) -> &mut dyn EquipParam; } ``` -------------------------------- ### Attribute Usage: #[for_all_subclasses] Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.for_all_subclasses.html?search=u32+-%3E+bool The attribute macro is applied to a trait impl. The trait name is not defined in the impl; instead, the macro defines it. The impl must include functions and should have a visibility modifier unless private is intended. ```rust #[for_all_subclasses] ``` -------------------------------- ### Using rename() field attribute Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html Shows the `rename()` field attribute to map a field to different names in specific structs. The struct must exactly match one passed to the outer annotation, and the name must be a valid identifier. ```rust #[multi_param( EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST, EQUIP_PARAM_PROTECTOR_ST, EQUIP_PARAM_WEAPON_ST )] pub trait EquipParam { fields! { weight: f32, basic_price: i32, sell_value: i32, sort_id: i32, vagrant_item_lot_id: i32, #[multi_param( rename(param = EQUIP_PARAM_PROTECTOR_ST, name = "vagrant_bonusene_drop_item_lot_id"), rename(param = EQUIP_PARAM_WEAPON_ST, name = "vagrant_bonusene_drop_item_lot_id"), )] vagrant_bonus_ene_drop_item_lot_id: i32; vagrant_item_ene_drop_item_lot_id: i32, } } ``` -------------------------------- ### multi_param Attribute Macro Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/attr.multi_param.html?search=u32+-%3E+bool Annotates a trait to automatically generate getters and setters for fields defined in a fields! macro, with implementations for each specified struct. Supports rename() field attribute to map fields to different names in specific structs. ```APIDOC ## Attribute Macro `multi_param` ### Description Annotates a trait to automatically generate getters and setters that forward to methods of the same name in various structs. This is used to create traits that encapsulate state shared across multiple parameter definitions. The macro takes as arguments the names of various structs for which it should automatically generate an implementation. It should annotate a trait that contains a `fields!` macro, using the same named field syntax that a struct uses. For each field, a getter and setter is generated both in the trait and in its implementation for each struct. ### Usage ```rust #[multi_param(EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST)] pub trait EquipParamPassive: EquipParam { fields! { sfx_variation_id: i32, ref_category: u8, sp_effect_category: u8, shop_lv: i16, } } ``` ### Field Attributes This can also be used to annotate field attributes. #### `rename()` You can use the `rename()` annotation to rename the field this targets for a particular struct. This can be useful if the same logical field has different names, which sometimes happens due to typos in FromSoftware’s internal names. The syntax is `#[multi_param(rename(param = ..., name = ...))]`. The struct must exactly match one of the structs passed to the outer annotation, and the `name` must be a valid identifier. ```rust #[multi_param( EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GOODS_ST, EQUIP_PARAM_PROTECTOR_ST, EQUIP_PARAM_WEAPON_ST )] pub trait EquipParam { fields! { weight: f32, basic_price: i32, sell_value: i32, sort_id: i32, vagrant_item_lot_id: i32, #[multi_param( rename(param = EQUIP_PARAM_PROTECTOR_ST, name = "vagrant_bonusene_drop_item_lot_id"), rename(param = EQUIP_PARAM_WEAPON_ST, name = "vagrant_bonusene_drop_item_lot_id"), )] vagrant_bonus_ene_drop_item_lot_id: i32; vagrant_item_ene_drop_item_lot_id: i32, } } ``` ### Generated Enums Each trait also generates two enums, one mutable and one immutable, which can be used in contexts where it's relevant *which* param type in particular you have. These enums have a variant for each defined parameter type. The above example would define: ```rust pub enum EquipParamStruct<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a EQUIP_PARAM_WEAPON_ST), } impl EquipParamStruct<'_> { pub fn as_dyn(&self) -> &dyn EquipParam; } pub enum EquipParamStructMut<'a> { EQUIP_PARAM_ACCESSORY_ST(&'a mut EQUIP_PARAM_ACCESSORY_ST), EQUIP_PARAM_GOODS_ST(&'a mut EQUIP_PARAM_GOODS_ST), EQUIP_PARAM_PROTECTOR_ST(&'a mut EQUIP_PARAM_PROTECTOR_ST), EQUIP_PARAM_WEAPON_ST(&'a mut EQUIP_PARAM_WEAPON_ST), } impl EquipParamStructMut<'_> { pub fn as_dyn(&mut self) -> &mut dyn EquipParam; } ``` You can access these using the `as_enum()` and `as_enum_mut()` methods. ``` -------------------------------- ### Derive Macro Superclass Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Superclass.html The `Superclass` derive macro generates an implementation of the `fromsoftware_shared::Superclass` trait for a struct. It can optionally generate subclass enums when the `#[superclass(children(...))]` attribute is used. ```APIDOC ## Derive Macro Superclass ### Description Generates an implementation of the `fromsoftware_shared::Superclass` trait for a struct. The macro obtains the VMT address from a standard RVA struct, assuming the crate has a `crate::rva` module with a `get()` function that returns a struct with a public field named as the snake_case struct name followed by `_vmt`. Optionally, with the `#[superclass(children(...))]` attribute, it also generates immutable and mutable subclass enums. ### Usage ```rust #[derive(Superclass)] { // Attributes available to this derive: #[superclass] } ``` ### Attributes - `#[superclass(children(ChildName1, ChildName2))]` - Optional. When present, generates two enums: `StructNameSubclasses` and `StructNameSubclassesMut`, along with their implementations and `From` conversions. ### Generated Code Example For a struct `Animal` with children `Cow` and `Pig`: ```rust #[repr(C)] #[derive(Superclass)] #[superclass(children(Cow, Pig))] pub struct Animal { _vftable: usize, } ``` generates: ```rust pub enum AnimalSubclasses<'sub> { Cow(&'sub Cow), Pig(&'sub Pig), Animal(&'sub Animal), } pub enum AnimalSubclassesMut<'sub> { Cow(&'sub mut Cow), Pig(&'sub mut Pig), Animal(&'sub mut Animal), } impl AnimalSubclasses<'_> { pub fn superclass(&self) -> &Animal; } impl AnimalSubclassesMut<'_> { pub fn superclass(&self) -> &Animal; pub fn superclass_mut(&mut self) -> &mut Animal; } impl<'sub> From> for AnimalSubclasses<'sub> {} impl<'sub> From<&'sub T> for AnimalSubclasses<'sub> where T: Subclass {} impl<'sub> From<&'sub mut T> for AnimalSubclassesMut<'sub> where T: Subclass {} ``` ### Safety This derive macro does not add any additional safety guarantees beyond a manual implementation. The `fromsoftware_shared::Superclass` trait is unsafe, and users must read its documentation carefully to understand the requirements. ``` -------------------------------- ### Generated subclass enums and implementations Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.Superclass.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The code generated by the `Superclass` derive macro when the `children` attribute is used. It defines immutable and mutable subclass enums, along with their implementations and conversions. ```rust pub enum AnimalSubclasses<'sub> { Cow(&'sub Cow), Pig(&'sub Pig), Animal(&'sub Animal), } pub enum AnimalSubclassesMut<'sub> { Cow(&'sub mut Cow), Pig(&'sub mut Pig), Animal(&'sub mut Animal), } impl AnimalSubclasses<'_> { pub fn superclass(&self) -> &Animal; } impl AnimalSubclassesMut<'_> { pub fn superclass(&self) -> &Animal; pub fn superclass_mut(&mut self) -> &mut Animal; } impl<'sub> From> for AnimalSubclasses<'sub> {} impl<'sub> From<&'sub T> for AnimalSubclasses<'sub> where T: Subclass {} impl<'sub> From<&'sub mut T> for AnimalSubclassesMut<'sub> where T: Subclass {} ``` -------------------------------- ### Derive StepperStates macro usage Source: https://docs.rs/fromsoftware-shared-macros/latest/fromsoftware_shared_macros/derive.StepperStates.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Use this attribute to derive the StepperStates trait on an enum. The enum must be exhaustive, have a -1 state for inactive steppers, and have no gaps in discriminants. Failing to meet these requirements can lead to undefined behavior or out-of-bounds access. ```rust #[derive(StepperStates)] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.