AttributeExt

Trait AttributeExt 

Source
pub trait AttributeExt: Debug {
Show 22 methods // Required methods fn id(&self) -> AttrId; fn name(&self) -> Option<Symbol>; fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>; fn value_str(&self) -> Option<Symbol>; fn value_span(&self) -> Option<Span>; fn path_matches(&self, name: &[Symbol]) -> bool; fn is_doc_comment(&self) -> Option<Span>; fn span(&self) -> Span; fn is_word(&self) -> bool; fn path_span(&self) -> Option<Span>; fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>>; fn doc_str(&self) -> Option<Symbol>; fn deprecation_note(&self) -> Option<Ident>; fn is_automatically_derived_attr(&self) -> bool; fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)>; fn doc_resolution_scope(&self) -> Option<AttrStyle>; fn is_doc_hidden(&self) -> bool; fn is_doc_keyword_or_attribute(&self) -> bool; // Provided methods fn has_name(&self, name: Symbol) -> bool { ... } fn has_any_name(&self, names: &[Symbol]) -> bool { ... } fn path(&self) -> SmallVec<[Symbol; 1]> { ... } fn is_proc_macro_attr(&self) -> bool { ... }
}

Required Methods§

Source

fn id(&self) -> AttrId

Source

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

For a single-segment attribute (i.e., #[attr] and not #[path::atrr]), return the name of the attribute; otherwise, returns None.

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 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) -> Option<Span>

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 path_span(&self) -> Option<Span>

Source

fn symbol_path(&self) -> Option<SmallVec<[Symbol; 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 deprecation_note(&self) -> Option<Ident>

Returns the deprecation note if this is deprecation attribute.

  • #[deprecated = "note"] returns Some("note").
  • #[deprecated(note = "note", ...)] returns Some("note").
Source

fn is_automatically_derived_attr(&self) -> bool

Source

fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)>

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 doc_resolution_scope(&self) -> Option<AttrStyle>

Returns outer or inner if this is a doc attribute or a sugared doc comment, otherwise None.

This is used in the case of doc comments on modules, to decide whether to resolve intra-doc links against the symbols in scope within the commented module (for inner doc) vs within its parent module (for outer doc).

Source

fn is_doc_hidden(&self) -> bool

Returns true if this attribute contains doc(hidden).

Source

fn is_doc_keyword_or_attribute(&self) -> bool

Returns true is this attribute contains doc(keyword) or doc(attribute).

Provided Methods§

Source

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

Source

fn has_any_name(&self, names: &[Symbol]) -> bool

Source

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

Source

fn is_proc_macro_attr(&self) -> bool

Implementors§