Skip to content

Feat: Sets Spread Across An Entire Crate #17

@mcmah309

Description

@mcmah309

Some users may find it useful to allow sets to be spread across the entire crate. Due to the way Rust works this is not possible without a different approach.

Proposal

  • Add a feature flag - code_gen. This flag will enable an error_set_part! macro.
  • Create a build runner to run in build.rs that scans all files for error_set_part! definitions and combines all definitions in a file like error_set.rs with a single error_set! macro.
  • Since error_set_part! can know the name of each error type it needs and the output location is constant, it can evaluate to import the correct enums from this file. e.g.
error_set_part! {
    Error1 = ...
    Error2 = ...
}

->

use crate::error_set::Error1;
use crate::error_set::Error2;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions