Attribute in rustc_ast::ast - Rust (original) (raw)
pub struct Attribute {
pub kind: AttrKind,
pub id: AttrId,
pub style: AttrStyle,
pub span: Span,
}
Expand description
A syntax-level representation of an attribute.
Denotes if the attribute decorates the following construct (outer) or the construct this attribute is contained within (inner).
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
.
For a single-segment attribute, returns its name; otherwise, returns None
.
Returns a list of meta items if the attribute is delimited with parenthesis:
#[attr(a, b = "c")] // Returns `Some()`.
#[attr = ""] // Returns `None`.
#[attr] // Returns `None`.
Returns the string value in:
#[attribute = "value"]
^^^^^^^
It returns None
in any other cases, including doc comments if they are not under the form #[doc = "..."]
.
It also returns None
for:
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
.
Returns the documentation if this is a doc comment or a sugared doc comment.
///doc
returnsSome("doc")
.#[doc = "doc"]
returnsSome("doc")
.#[doc(...)]
returnsNone
.
Gets the span of the value literal, as string, when using #[attr = value]
Returns None for doc comments
Checks whether the path of this attribute matches the name. Read more
get the span of the entire attribute
For a single-segment attribute (i.e., #[attr]
and not #[path::atrr]
), return the name of the attribute; otherwise, returns None
.
This is true
if this HasAttrs
might support ‘custom’ (proc-macro) inner attributes. Attributes like #![cfg]
and #![cfg_attr]
are not considered ‘custom’ attributes. Read more
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