Expand description
toml-maid formats TOML files using toml_edit, which preserves all
whitespace and comments as “decorations” attached to keys and values.
§toml_edit decor model
Every key and value carries a Decor with a prefix (text before) and
suffix (text after). Understanding this layout is necessary to follow the
format_* functions.
Arrays — commas are separators, not part of any element’s decor:
[ PREFIX₁ VALUE₁ SUFFIX₁ , PREFIX₂ VALUE₂ SUFFIX₂ , … TRAILING ]Because the suffix sits before the comma, a suffix comment like # note
would absorb the comma (value # note, → invalid). This formatter therefore
moves suffix comments forward into the next element’s prefix, so they
appear on the same line after the comma: value, # note. The last
element’s suffix moves into TRAILING.
Tables — each entry is:
KEY_PREFIX KEY = VALUE KEY_SUFFIX \nA KEY_PREFIX that starts with \n indicates a blank line in the source,
which marks a section boundary. Keys within a section are sorted; the
relative order of sections is preserved. The first key’s prefix is lifted
out as a “section header” decoration and re-applied to whichever key sorts
to the front.
Structs§
- Check
Failed - Error returned by
Config::process_filewhen--checkmode detects that a file is not correctly formatted. Callers that need a specific exit code (e.g. exit 2 for CI) should downcast to this type. - Config
Enums§
- Mode
- Operating mode for
Config::process_file.
Functions§
Type Aliases§
- Res
- Type alias for shorter return types.