mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
This is a follow up to #1901 and #1882. Depends on #1967. Essentially before this change, `Purchases` had both `StoreKit1Wrapper?` and a `PaymentQueueWrapper`. The later wasn't actually needed when the first was not-nil, so it was essentially storing `(a?, b?)`. What we really wanted to express is that it could have one OR the other. This introduces `Either` to express this requirement in the type system, as well as `PaymentQueueWrapperType` that will be used to fix #1964.
41 lines
785 B
Swift
41 lines
785 B
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// Either.swift
|
|
//
|
|
// Created by Nacho Soto on 10/7/22.
|
|
|
|
import Foundation
|
|
|
|
/// A type that may contain one of two possible values.
|
|
internal enum Either<Left, Right> {
|
|
|
|
case left(Left)
|
|
case right(Right)
|
|
|
|
}
|
|
|
|
extension Either {
|
|
|
|
var left: Left? {
|
|
switch self {
|
|
case let .left(left): return left
|
|
case .right: return nil
|
|
}
|
|
}
|
|
|
|
var right: Right? {
|
|
switch self {
|
|
case .left: return nil
|
|
case let .right(right): return right
|
|
}
|
|
}
|
|
|
|
}
|