Structure
Extension
public struct Extension: Declaration, Hashable, Codable
An extension declaration.
Relationships
Conforms To
Declaration
A Swift declaration.
ExpressibleBySyntax
A type that can be initialized with a Swift syntax node.
Codable
CustomStringConvertible
Hashable
Initializers
init(_:)
public init(_ node: ExtensionDeclSyntax)
Creates an instance initialized with the given syntax node.
Properties
keyword
let keyword: String
The declaration keyword ("extension"
).
extendedType
let extendedType: String
The name of the type extended by the extension.
inheritance
let inheritance: [String]
A list of protocol names inherited by the extended type.
For example,
the following extension on structure S
has an inheritance
of ["P", "Q"]
:
struct S {}
protocol P {}
protocol Q {}
extension S: P, Q {}
genericRequirements
let genericRequirements: [GenericRequirement]
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 {}
description
var description: String