vds_ios/VDS/Protocols/EnumSubset.swift
Matt Bruce 16e8067f8e commented code
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-07-26 10:23:38 -05:00

22 lines
454 B
Swift

//
// EnumSubset.swift
// VDS
//
// Created by Matt Bruce on 12/19/22.
//
import Foundation
public protocol EnumSubset<T>: RawRepresentable, CaseIterable {
associatedtype T:RawRepresentable
var defaultValue: T { get }
}
extension EnumSubset where RawValue == T.RawValue {
/// Will either return the Generic RawRepresentable object or the defaultValue
public var value: T {
T(rawValue: rawValue) ?? defaultValue
}
}