IndirectReference

public struct IndirectReference<T> : Hashable where T : Hashable

Allows recursively referencing a struct within itself.

struct Node {
   // MARK: - Public Properties
   let id: Int

   var left: Node {
       self._left.value
   }
   var right: Node {
       self._right.value
   }

   // MARK: - Private Properties
   private let _left: IndirectReference<Node>
   private let _right: IndirectReference<Node>
}

Public Properties

  • Set/get the referenced value.

    Declaration

    Swift

    public var value: T { get set }

Equatable

  • Declaration

    Swift

    public static func == (lhs: IndirectReference<T>, rhs: IndirectReference<T>) -> Bool

Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)

Initializers

  • Creates an instance referencing the provided value.

    Declaration

    Swift

    public init(_ value: T)

    Parameters

    value

    The value to reference

    Return Value

    The instance