Skip to main content

format

Function format 

Source
pub fn format(source: &str, config: &FmtConfig) -> String
Expand description

Format source, returning the tidied text. In safe_mode (the default) this returns source unchanged rather than risk a meaning-changing edit (a syntax error in the input, or output whose significant tokens differ from the input’s).

The source’s line-ending style is preserved: a file using \r\n (a Windows checkout) is formatted internally in \n and re-emitted with \r\n, so the formatter never churns every line by flipping CRLF to LF (matching gdformat, which preserves line endings).