Skip to main content

rustfmt

Function rustfmt 

Source
pub fn rustfmt(src: &str) -> Result<String, FmtError>
Expand description

Hoist long paths into imports, pretty-print src with prettyplease, refine it through rustfmt at edition 2024, and return the formatted output.

src must be a complete Rust source file, which every generated file is. This function keeps the leading //-style banner comment. syn discards line comments, so the function removes the banner before it pretty-prints and re-attaches the banner afterwards.

ยงErrors

Returns an error when the schema model is invalid or generated Rust cannot be formatted or written.