pub struct Comment<'input> {
pub span: Span,
pub text: Cow<'input, str>,
pub placement: Placement,
}Expand description
A YAML comment captured from the source.
Comments are presentation metadata, not YAML data. This type carries the raw comment payload,
source span, and a best-effort Placement hint for callers that want to correlate comments
with nearby YAML presentation.
Fields§
§span: SpanSpan covering the whole source comment, including # and excluding the line break.
text: Cow<'input, str>Raw comment payload exactly after #, excluding only the line break.
Leading spaces are preserved, including a single space immediately after # when present.
placement: PlacementBest-effort placement of this comment relative to nearby YAML content.
Implementations§
Source§impl<'input> Comment<'input>
impl<'input> Comment<'input>
Sourcepub fn new(span: Span, text: impl Into<Cow<'input, str>>) -> Self
pub fn new(span: Span, text: impl Into<Cow<'input, str>>) -> Self
Create a captured YAML comment from a source span and raw payload.
The placement defaults to Placement::Free. Use Comment::with_placement when the
caller already knows a more specific placement.
Sourcepub fn with_placement(self, placement: Placement) -> Self
pub fn with_placement(self, placement: Placement) -> Self
Return this comment with the given placement.
Sourcepub fn trimmed_text(&self) -> &str
pub fn trimmed_text(&self) -> &str
Return the comment payload with surrounding whitespace removed.
This helper is ergonomic only. The raw Self::text payload remains unchanged.