pub fn write_code<T: AsRef<str>>(
    code: T,
    format: DumpCodeFormat,
    config: &DumpCodeConfig,
) -> WeldResult<()> {
    // Code dumping is not enabled - return.
    if !config.enabled {
        return Ok(());
    }

    // Format not registered: return.
    if !config.formats.contains(&format) {
        return Ok(());
    }

    let path = &mut PathBuf::new();
    path.push(&config.directory);
    path.push(&format!("{}{}", &config.filename, format.suffix()));
    path.set_extension(format.extension());

    info!("Writing code to {}", path.to_str().unwrap());

    let mut options = OpenOptions::new();
    let mut file = options.write(true).create_new(true).open(path)?;

    file.write_all(code.as_ref().as_bytes())?;
    Ok(())
}
Writes code to a file using the given configuration.

The format determines the extension used for the dumped file.
weld/src/util/dump.rs