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§
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 name; 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) -> bool
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
.
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.
///doc
returnsSome("doc")
.#[doc = "doc"]
returnsSome("doc")
.#[doc(...)]
returnsNone
.
Sourcefn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)>
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
returnsSome(("doc", CommentKind::Line))
./** doc */
returnsSome(("doc", CommentKind::Block))
.#[doc = "doc"]
returnsSome(("doc", CommentKind::Line))
.#[doc(...)]
returnsNone
.