SwiftSemantics Documentation Beta

Structure Generic​Requirement

public struct GenericRequirement: Hashable, Codable

A generic requirement.

A generic type or function declaration may specifying one or more requirements in a generic where clause before the opening curly brace ({) its body. Each generic requirement establishes a relation between two type identifiers.

For example, the following declaration specifies two generic requirements:

func difference<C1: Collection, C2: Collection>(between lhs: C1, and rhs: C2) -> [C1.Element]
   where C1.Element: Equatable, C1.Element == C2.Element
%3 GenericRequirement GenericRequirement Hashable Hashable GenericRequirement->Hashable Codable Codable GenericRequirement->Codable CustomStringConvertible CustomStringConvertible GenericRequirement->CustomStringConvertible

Nested Types

GenericRequirement.Relation

A relation between the two types identified in the generic requirement.

Conforms To

Codable
CustomStringConvertible
Hashable

Properties

relation

let relation: Relation

The relation between the two identified types.

left​Type​Identifier

let leftTypeIdentifier: String

The identifier for the left-hand side type.

right​Type​Identifier

let rightTypeIdentifier: String

The identifier for the right-hand side type.

description

var description: String

Methods

generic​Requirements(from:​)

public static func genericRequirements(from node: GenericRequirementListSyntax?) -> [GenericRequirement]

Creates and returns generic requirements initialized from a generic requirement list syntax node.

Parameters

from Generic​Requirement​List​Syntax?

The generic requirement list syntax node, or nil.

Returns

An array of generic requirements, or nil if the node is nil.