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).

Source§

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§

For a single-segment attribute, returns its name; otherwise, returns None.

Source§

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`.

Source§

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:

Source§

Returns the documentation and its kind if this is a doc comment or a sugared doc comment.

Source§

Returns the documentation if this is a doc comment or a sugared doc comment.

Source§

Source§

Gets the span of the value literal, as string, when using #[attr = value]

Source§

Returns None for doc comments

Source§

Checks whether the path of this attribute matches the name. Read more

Source§

get the span of the entire attribute

Source§

Source§

Source§

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

Source§

Source§

Source§

Source§

Source§

Source§

Source§

Source§

Source§

Source§

Source§

Source§

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

Source§

Source§

Source§

Source§

Source§

§

§

§

§

§

§

§

§

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