Skip to main content

generate

Function generate 

Source
pub fn generate<P: AsRef<Path>>(path: P) -> Result<()>
Expand description

Generate proc-macro code from a TOML configuration file.

This function parses the TOML configuration at path and generates proc-macro code in the OUT_DIR directory. The generated code should be included in your proc-macro crate.

§Errors

Returns an error if:

  • The configuration file cannot be read
  • The TOML is invalid
  • There are validation errors (circular dependencies, undefined parents, etc.)
  • The output file cannot be written

§Example

derive_defs::generate("derive_defs.toml")
    .expect("Failed to generate derive defs");

§Panics

This function panics if the OUT_DIR environment variable is not set. This should only happen if called outside of a build script context.