Skip to main content

Groupped

Derive Macro Groupped 

Source
#[derive(Groupped)]
{
    // Attributes available to this derive:
    #[group]
}
Expand description

derive macro Groupped Derive macro for automatically implementing the Groupped trait on a struct.

The #[derive(Groupped)] macro:

  1. Implements Groupped<Group> where the group is specified via #[group(GroupName)].
  2. Registers the type via register_type! so it’s included in the program enum.
  3. Generates Into<AnyOutput<Group>> and Into<ChainProcess<Group>> conversions.
  4. Adds to_chain() and to_render() methods to the struct.

§Syntax

#[derive(Groupped)]
#[group(MyProgram)]   // optional; defaults to `ThisProgram`
struct MyStruct {
    field: String,
}

§Example

use mingling::{Groupped, macros::{chain, gen_program, renderer, r_println}};

#[derive(Groupped)]
#[group(ThisProgram)]
struct Greeting {
    name: String,
}

This is equivalent to using pack! but works with custom structs that have named fields. For simple wrappers, prefer pack!.