Skip to main content

format_directives

Function format_directives 

Source
pub fn format_directives<'a, I>(directives: I, config: &FormatConfig) -> String
where I: IntoIterator<Item = &'a Directive>,
Expand description

Format a list of directives to a string, aligning all of them together against shared, file-wide column widths in a single pass.

This is the canonical entry point for callers that have a list of Directives but no surrounding source text (e.g. synthesized output, extract, plugin round-trips). Callers that also need to preserve comments, blank lines, and non-directive elements from original source should use rustledger_parser::format::format_source instead.

Passing a single directive ([&directive]) formats it on its own, which is the natural degenerate case of whole-list alignment.

§Separator policy

No blank line is inserted between adjacent directivesformat_directives concatenates each rendered directive directly so it’s safe to use as a building block in larger compositions. Callers that need a blank line between directives should drop down to format_directive_lines + render_lines and push a FormatLine::Plain(String::new()) between each directive’s lines (see crates/rustledger/src/cmd/extract_cmd for an example).