pub struct CommentMap<'a, 'src> { /* private fields */ }Expand description
Associates comments with statement spans using a leading-comment heuristic.
A comment is “leading” for a statement if it appears before the statement and no other statement is closer. Comments after the last statement are “trailing”.
Implementations§
Source§impl<'a, 'src> CommentMap<'a, 'src>
impl<'a, 'src> CommentMap<'a, 'src>
Sourcepub fn build<'arena>(
comments: &'a [Comment<'src>],
stmts: &[Stmt<'arena, 'src>],
) -> Self
pub fn build<'arena>( comments: &'a [Comment<'src>], stmts: &[Stmt<'arena, 'src>], ) -> Self
Build a comment map from a list of comments and statements.
Both comments and stmts must be in source order (which they are
as produced by the parser).
Sourcepub fn leading_comments(&self, stmt_span: Span) -> &[&'a Comment<'src>]
pub fn leading_comments(&self, stmt_span: Span) -> &[&'a Comment<'src>]
Get comments that lead the statement at the given span.
Sourcepub fn trailing_comments(&self) -> &[&'a Comment<'src>]
pub fn trailing_comments(&self) -> &[&'a Comment<'src>]
Get comments that appear after all statements.
Sourcepub fn iter_leading(&self) -> impl Iterator<Item = (u32, &[&'a Comment<'src>])>
pub fn iter_leading(&self) -> impl Iterator<Item = (u32, &[&'a Comment<'src>])>
Iterate over all (stmt_start_offset, comments) pairs.
Auto Trait Implementations§
impl<'a, 'src> Freeze for CommentMap<'a, 'src>
impl<'a, 'src> RefUnwindSafe for CommentMap<'a, 'src>
impl<'a, 'src> Send for CommentMap<'a, 'src>
impl<'a, 'src> Sync for CommentMap<'a, 'src>
impl<'a, 'src> Unpin for CommentMap<'a, 'src>
impl<'a, 'src> UnsafeUnpin for CommentMap<'a, 'src>
impl<'a, 'src> UnwindSafe for CommentMap<'a, 'src>
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