Extension
public struct Extension : Declaration, Hashable, Codable
extension Extension: ExpressibleBySyntax
extension Extension: CustomStringConvertible
An extension declaration.
-
The declaration attributes.
Declaration
Swift
public let attributes: [Attribute]
-
The declaration modifiers.
Declaration
Swift
public let modifiers: [Modifier]
-
The declaration keyword (
"extension"
).Declaration
Swift
public let keyword: String
-
The name of the type extended by the extension.
Declaration
Swift
public let extendedType: String
-
A list of protocol names inherited by the extended type.
For example, the following extension on structure
S
has aninheritance
of["P", "Q"]
:struct S {} protocol P {} protocol Q {} extension S: P, Q {}
Declaration
Swift
public let inheritance: [String]
-
The generic parameter requirements for the declaration.
For example, the following conditional extension on structure S has a single requirement that its generic parameter identified as
"T"
conforms to the type identified as"Hahable"
:struct S<T> {} extension S where T: Hashable {}
Declaration
Swift
public let genericRequirements: [GenericRequirement]
-
Creates an instance initialized with the given syntax node.
Declaration
Swift
public init(_ node: ExtensionDeclSyntax)
-
Declaration
Swift
public var description: String { get }