Structure
Function
public struct Function: Declaration, Hashable, Codable
A function declaration.
Relationships
Nested Types
Function.Signature
A function signature.
Function.Parameter
A function parameter.
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: FunctionDeclSyntax)
Creates an instance initialized with the given syntax node.
Properties
keyword
let keyword: String
The declaration keyword ("func"
).
identifier
let identifier: String
The function identifier.
signature
let signature: Signature
The function signature.
genericParameters
let genericParameters: [GenericParameter]
The generic parameters for the declaration.
For example,
the following declaration of function f
has a single generic parameter
whose identifier
is "T"
and type
is "Equatable"
:
func f<T: Equatable>(value: T) {}
genericRequirements
let genericRequirements: [GenericRequirement]
The generic parameter requirements for the declaration.
For example,
the following declaration of function f
has a single requirement
that its generic parameter identified as "T"
conforms to the type identified as "Hahable"
:
func f<T>(value: T) where T: Hashable {}
isOperator
var isOperator: Bool
Whether the function is an operator.
description
var description: String