SwiftSemantics Documentation Beta

Structure Attribute

public struct Attribute: Hashable, Codable

A declaration attribute.

Attributes provide additional information about a declaration. For example, the @discardableResult attribute indicates that a function may be called without using the result.

%3 Attribute Attribute Codable Codable Attribute->Codable ExpressibleBySyntax ExpressibleBySyntax Attribute->ExpressibleBySyntax CustomStringConvertible CustomStringConvertible Attribute->CustomStringConvertible Hashable Hashable Attribute->Hashable

Nested Types

Attribute.Argument

An attribute argument.

Conforms To

ExpressibleBySyntax

A type that can be initialized with a Swift syntax node.

Codable
CustomStringConvertible
Hashable

Initializers

init(_:​)

public init(_ node: AttributeSyntax)

Creates an instance initialized with the given syntax node.

Properties

name

let name: String

The attribute name.

An attribute's name is everything after the at-sign (@) and before the argument clause. For example, the name of the attribute in the following declaration is "available":

@available(macOS 10.15, iOS 13, *)

arguments

let arguments: [Argument]

The attribute's arguments, if any.

description

var description: String