pub struct Attribute {
pub kind: AttrKind,
pub id: AttrId,
pub style: AttrStyle,
pub span: Span,
}
Expand description
A syntax-level representation of an attribute.
Fields§
§kind: AttrKind
§id: AttrId
§style: AttrStyle
Denotes if the attribute decorates the following construct (outer) or the construct this attribute is contained within (inner).
span: Span
Implementations§
source§impl Attribute
impl Attribute
pub fn get_normal_item(&self) -> &AttrItem
pub fn unwrap_normal_item(self) -> AttrItem
sourcepub fn is_doc_comment(&self) -> bool
pub 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
.
sourcepub fn ident(&self) -> Option<Ident>
pub fn ident(&self) -> Option<Ident>
For a single-segment attribute, returns its name; otherwise, returns None
.
pub fn name_or_empty(&self) -> Symbol
pub fn path(&self) -> SmallVec<[Symbol; 1]>
pub fn has_name(&self, name: Symbol) -> bool
pub fn path_matches(&self, name: &[Symbol]) -> bool
pub fn is_word(&self) -> bool
pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>
pub fn value_str(&self) -> Option<Symbol>
sourcepub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)>
pub 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
.
sourcepub fn doc_str(&self) -> Option<Symbol>
pub 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
.
pub fn may_have_doc_links(&self) -> bool
pub fn is_proc_macro_attr(&self) -> bool
pub fn meta_kind(&self) -> Option<MetaItemKind>
pub fn token_trees(&self) -> Vec<TokenTree>
Trait Implementations§
source§impl<__D: SpanDecoder> Decodable<__D> for Attribute
impl<__D: SpanDecoder> Decodable<__D> for Attribute
source§impl<__E: SpanEncoder> Encodable<__E> for Attribute
impl<__E: SpanEncoder> Encodable<__E> for Attribute
source§impl HasAttrs for Attribute
impl HasAttrs for Attribute
source§const SUPPORTS_CUSTOM_INNER_ATTRS: bool = false
const SUPPORTS_CUSTOM_INNER_ATTRS: bool = false
true
if this HasAttrs
might support ‘custom’ (proc-macro) inner
attributes. Attributes like #![cfg]
and #![cfg_attr]
are not
considered ‘custom’ attributes. Read morefn attrs(&self) -> &[Attribute]
fn visit_attrs(&mut self, _f: impl FnOnce(&mut AttrVec))
source§impl HasTokens for Attribute
impl HasTokens for Attribute
fn tokens(&self) -> Option<&LazyAttrTokenStream>
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>>
source§impl<AstCtx: HashStableContext> HashStable<AstCtx> for Attribute
impl<AstCtx: HashStableContext> HashStable<AstCtx> for Attribute
fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher)
Auto Trait Implementations§
impl DynSend for Attribute
impl DynSync for Attribute
impl Freeze for Attribute
impl !RefUnwindSafe for Attribute
impl !Send for Attribute
impl !Sync for Attribute
impl Unpin for Attribute
impl !UnwindSafe for Attribute
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes