rustc_ast::attr

Trait AttributeExt

Source
pub trait AttributeExt: Debug {
Show 17 methods // Required methods fn id(&self) -> AttrId; fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>; fn value_str(&self) -> Option<Symbol>; fn value_span(&self) -> Option<Span>; fn ident(&self) -> Option<Ident>; fn path_matches(&self, name: &[Symbol]) -> bool; fn is_doc_comment(&self) -> bool; fn span(&self) -> Span; fn is_word(&self) -> bool; fn ident_path(&self) -> Option<SmallVec<[Ident; 1]>>; fn doc_str(&self) -> Option<Symbol>; fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)>; fn style(&self) -> AttrStyle; // Provided methods fn name_or_empty(&self) -> Symbol { ... } fn has_name(&self, name: Symbol) -> bool { ... } fn path(&self) -> SmallVec<[Symbol; 1]> { ... } fn is_proc_macro_attr(&self) -> bool { ... }
}

Required Methods§

Source

fn id(&self) -> AttrId

Source

fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>

Get the meta item list, #[attr(meta item list)]

Source

fn value_str(&self) -> Option<Symbol>

Gets the value literal, as string, when using #[attr = value]

Source

fn value_span(&self) -> Option<Span>

Gets the span of the value literal, as string, when using #[attr = value]

Source

fn ident(&self) -> Option<Ident>

For a single-segment attribute, returns its name; otherwise, returns None.

Source

fn path_matches(&self, name: &[Symbol]) -> bool

Checks whether the path of this attribute matches the name.

Matches one segment of the path to each element in name

Source

fn is_doc_comment(&self) -> bool

Returns true if it is a sugared doc comment (/// or //! for example). So #[doc = "doc"] (which is a doc comment) and #[doc(...)] (which is not a doc comment) will return false.

Source

fn span(&self) -> Span

get the span of the entire attribute

Source

fn is_word(&self) -> bool

Source

fn ident_path(&self) -> Option<SmallVec<[Ident; 1]>>

Returns None for doc comments

Source

fn doc_str(&self) -> Option<Symbol>

Returns the documentation if this is a doc comment or a sugared doc comment.

  • ///doc returns Some("doc").
  • #[doc = "doc"] returns Some("doc").
  • #[doc(...)] returns None.
Source

fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)>

Returns the documentation and its kind if this is a doc comment or a sugared doc comment.

  • ///doc returns Some(("doc", CommentKind::Line)).
  • /** doc */ returns Some(("doc", CommentKind::Block)).
  • #[doc = "doc"] returns Some(("doc", CommentKind::Line)).
  • #[doc(...)] returns None.
Source

fn style(&self) -> AttrStyle

Provided Methods§

Source

fn name_or_empty(&self) -> Symbol

Source

fn has_name(&self, name: Symbol) -> bool

Source

fn path(&self) -> SmallVec<[Symbol; 1]>

Source

fn is_proc_macro_attr(&self) -> bool

Implementors§