Skip to main content

generate

Function generate 

Source
pub fn generate(config: ResolvedConfig) -> Result<()>
Expand description

Generate proc-macro code to the default OUT_DIR.

This function reads the OUT_DIR environment variable set by Cargo during the build process and writes the generated code to $OUT_DIR/derive_defs.rs.

§Errors

Returns an error if:

  • The OUT_DIR environment variable is not set
  • The output file cannot be written

§Panics

Panics if OUT_DIR is not set. This should only happen outside of a build script.

§Example

// In your build.rs
derive_defs::generate("derive_defs.toml").unwrap();