Skip to content

Allow nested delegation of components #27

@soareschen

Description

@soareschen

Summary

With trait-generic providers like UseDelegate, it is common to have nested delegation of components. However, the current design of delegate_components! require the nested components to be defined with separate struct definitions and delegation.

New Syntax

The new delegate_components! macro would support nested delegation with the following syntax:

pub struct FooComponents;

delegate_components! {
  FooComponents {
    FooOneComponent: FooOneImpl,
    FooTwoComponent: UseDelegate<BarComponents {
      BarOneComponent: BarOneImpl,
      BarTwoComponent: BarTwoImpl,
    }>,
  }
}

Which would roughly expanded into the current syntax:

pub struct FooComponents;
pub struct BarComponents;


delegate_components! {
  FooComponents {
    FooOneComponent: FooOneImpl,
    FooTwoComponent: UseDelegate<BarComponents>,
  }
}

delegate_components! {
  BarComponents {
    BarOneComponent: BarOneImpl,
    BarTwoComponent: BarTwoImpl,
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions