Skip to main content

write_debug_output

Function write_debug_output 

Source
pub fn write_debug_output(mod_ident: &Ident, expanded: &TokenStream)
Expand description

Write a prettyprinted copy of expanded to disk when debug output is enabled.

Whether anything is written is decided at macro-expansion time from the OPENAPI_TRAIT_DEBUG environment variable:

  • unset, empty, 0, or false — disabled (no-op).
  • 1 or true — write to the default directory.
  • any other value — used verbatim as the target directory path.

The default directory is $OUT_DIR/openapi-trait-debug when OUT_DIR is set (i.e. the consuming crate has a build script), otherwise <system temp dir>/openapi-trait-debug. The file is named after the generated module (<mod_ident>.rs), and the resolved path is printed to stderr.

Failures are reported to stderr but never abort compilation: debug output is a convenience and must not turn a buildable crate into a broken one (e.g. on read-only filesystems).