pub fn format_program_preserving_comments(source: &str) -> Option<String>Expand description
Format source while preserving comments where they can be placed safely:
top-level leading comments (a # … or // … line above a declaration, or
a file-header block) and trailing comments on a single-line top-level
declaration (workflow Demo # …, attached to that element’s line); comments
inside raw-body declarations (rule/apply/coerce/table/flow, carried by
the body substring); and comments inside class/agent/enum bodies, including a
data-carrying enum variant’s nested field block — both own-line (interleaved
by source position) and trailing comments on a field/variant line (appended to
it), and signal/queue/file store bodies the same way — even though those
bodies rebuild from the AST. Returns None when the program does not parse, or
when a comment has nowhere to attach — e.g. one trailing a declaration’s
opening-brace line, with no field on that line. The caller refuses such files
rather than dropping comments.