Skip to content

Instantly share code, notes, and snippets.

@niw
Created August 16, 2025 11:52
Show Gist options
  • Select an option

  • Save niw/31623f57efbbe2f357f6fee47362fab0 to your computer and use it in GitHub Desktop.

Select an option

Save niw/31623f57efbbe2f357f6fee47362fab0 to your computer and use it in GitHub Desktop.

Revisions

  1. niw created this gist Aug 16, 2025.
    26 changes: 26 additions & 0 deletions Tuple.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    //
    // Tuple.swift
    // Tuple
    //
    // Created by Yoshimasa Niwa on 8/8/25.
    //

    public struct Tuple<each T: Equatable>: Equatable {
    public static func == (lhs: Tuple<repeat each T>, rhs: Tuple<repeat each T>) -> Bool {
    var result = true
    func compare<U: Equatable>(lhs: U, rhs: U) {
    if !result {
    return
    }
    result = lhs == rhs
    }
    repeat compare(lhs: each lhs.values, rhs: each rhs.values)
    return result
    }

    public var values: (repeat each T)

    public init(_ values: repeat each T) {
    self.values = (repeat each values)
    }
    }