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;
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
code_gen. This flag will enable anerror_set_part!macro.build.rsthat scans all files forerror_set_part!definitions and combines all definitions in a file likeerror_set.rswith a singleerror_set!macro.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.->