Skip to main content

comment_body

Function comment_body 

Source
pub fn comment_body(source: &str, span: Span) -> Cow<'_, str>
Expand description

Extract the body of a Comment trivia token: everything after the leading // marker, preserving its inline whitespace verbatim. Used by the parser when attaching comments to declarations.

#2203: a legacy -- comment’s body is what follows its --, so the formatter prints it after //. A legacy body that starts with a dash (a --- Helpers --- divider, read by tokenize_legacy) keeps all of its dashes behind a space instead, as // --- Helpers ---, and a legacy --| after code (#1888) drops its |.