Structure
Subscript
public struct Subscript: Declaration, Hashable, Codable
A subscript 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: SubscriptDeclSyntax)
Creates an instance initialized with the given syntax node.
Properties
keyword
let keyword: String
The declaration keyword ("subscript"
).
genericParameters
let genericParameters: [GenericParameter]
The generic parameters for the declaration.
For example,
the following subscript declaration
has a single generic parameter
whose name
is "T"
and type
is "Equatable"
:
subscript<T: Equatable>(value: T) {}
genericRequirements
let genericRequirements: [GenericRequirement]
The generic parameter requirements for the declaration.
For example,
the following subscript declaration
has a single requirement
that its generic parameter identified as "T"
conforms to the type identified as "Hahable"
:
subscript<T>(value: T) where T: Hashable {}
returnType
let returnType: String
The return type of the subscript.
description
var description: String