Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

GenericRequirement

mattt edited this page Jan 22, 2020 · 5 revisions

GenericRequirement

A generic requirement.

public struct GenericRequirement: Hashable, Codable

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

Inheritance

Hashable, Codable, CustomStringConvertible


Nested Types


Properties

relation

The relation between the two identified types.

let relation: Relation

leftTypeIdentifier

The identifier for the left-hand side type.

let leftTypeIdentifier: String

rightTypeIdentifier

The identifier for the right-hand side type.

let rightTypeIdentifier: String

description

var description: String

Methods

genericRequirements(from:)

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

public static func genericRequirements(from node: GenericRequirementListSyntax?) -> [GenericRequirement]
  • Parameter from: The generic requirement list syntax node, or nil.

Returns

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