Derive Macro Language

Source
#[derive(Language)]
Expand description

The macro to derive Recursive and corresponding Language, Patterns and smart constructor traits for a given recursive AST.

The type passed to Language must satisfy the following conditions:

  1. It MUST NOT have any generic parameters.
  2. It MUST be an enum.
  3. Recursive variants MUST mention itself by Self, not the concrete name.
  4. Recursive variants MUST have exactly on fields with one of the following type:
    • Box<Self>
    • [Box<Self>; N] for constant N
    • Vec<Self>
    • T<Box<Self>> for T: IntoLanguageChildren.
  5. Non-recursive variants MUST NOT mention the type itself, and all the arguments must implement [Eq], [Ord], [Hash], and [Clone].