pub trait AttributeExt: Debug {
Show 21 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) -> Option<Span>;
fn span(&self) -> Span;
fn is_word(&self) -> bool;
fn ident_path(&self) -> Option<SmallVec<[Ident; 1]>>;
fn doc_str(&self) -> Option<Symbol>;
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 name(&self) -> Option<Symbol> { ... }
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§
fn id(&self) -> AttrId
Sourcefn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>
fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>
Get the meta item list, #[attr(meta item list)]
Sourcefn value_str(&self) -> Option<Symbol>
fn value_str(&self) -> Option<Symbol>
Gets the value literal, as string, when using #[attr = value]
Sourcefn value_span(&self) -> Option<Span>
fn value_span(&self) -> Option<Span>
Gets the span of the value literal, as string, when using #[attr = value]
Sourcefn ident(&self) -> Option<Ident>
fn ident(&self) -> Option<Ident>
For a single-segment attribute, returns its ident; otherwise, returns None.
Sourcefn path_matches(&self, name: &[Symbol]) -> bool
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
Sourcefn is_doc_comment(&self) -> Option<Span>
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.
fn is_word(&self) -> bool
Sourcefn doc_str(&self) -> Option<Symbol>
fn doc_str(&self) -> Option<Symbol>
Returns the documentation if this is a doc comment or a sugared doc comment.
///docreturnsSome("doc").#[doc = "doc"]returnsSome("doc").#[doc(...)]returnsNone.
fn is_automatically_derived_attr(&self) -> bool
Sourcefn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)>
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.
///docreturnsSome(("doc", CommentKind::Line))./** doc */returnsSome(("doc", CommentKind::Block)).#[doc = "doc"]returnsSome(("doc", CommentKind::Line)).#[doc(...)]returnsNone.
Sourcefn doc_resolution_scope(&self) -> Option<AttrStyle>
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).
Returns true if this attribute contains doc(hidden).
Sourcefn is_doc_keyword_or_attribute(&self) -> bool
fn is_doc_keyword_or_attribute(&self) -> bool
Returns true is this attribute contains doc(keyword) or doc(attribute).
Provided Methods§
Sourcefn name(&self) -> Option<Symbol>
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.