pub struct Comment<'input> { /* private fields */ }Expand description
Implementations§
Source§impl<'input> Comment<'input>
impl<'input> Comment<'input>
Sourcepub fn new(text: impl Into<Cow<'input, str>>) -> Self
pub fn new(text: impl Into<Cow<'input, str>>) -> Self
Create captured YAML comment metadata from a 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 text(&self) -> &str
pub fn text(&self) -> &str
Return the raw comment payload exactly after #, excluding only the line break.
Sourcepub const fn placement(&self) -> Placement
pub const fn placement(&self) -> Placement
Return the best-effort placement of this comment relative to nearby YAML content.
Sourcepub fn into_text(self) -> Cow<'input, str>
pub fn into_text(self) -> Cow<'input, str>
Consume the comment and return its raw payload without cloning.
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.
Trait Implementations§
impl<'input> Eq for Comment<'input>
impl<'input> StructuralPartialEq for Comment<'input>
Auto Trait Implementations§
impl<'input> Freeze for Comment<'input>
impl<'input> RefUnwindSafe for Comment<'input>
impl<'input> Send for Comment<'input>
impl<'input> Sync for Comment<'input>
impl<'input> Unpin for Comment<'input>
impl<'input> UnsafeUnpin for Comment<'input>
impl<'input> UnwindSafe for Comment<'input>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more