Skip to main content

format

Function format 

Source
pub fn format(input: &str) -> Result<String>
Expand description

Auto-formats a messy YAML file into a canonical style based on the CST.

This uses the default configuration (2 spaces indentation).

The output always parses to the same values as the input. A stream the formatter cannot re-layout without changing its meaning (for example a multi-line flow collection whose continuation lines would end up at or left of a re-indented key) is refused with an error rather than rewritten.

ยงErrors

Returns the parse error of an invalid input, a budget error under the default ParserConfig, or an error when the input cannot be re-laid out without changing its meaning.