DataLireCoder swift package
This commit is contained in:
15
Sources/DLCEncoder/Protocols/Flattenable.swift
Normal file
15
Sources/DLCEncoder/Protocols/Flattenable.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
import Foundation
|
||||
|
||||
protocol Flattenable {
|
||||
func flattened() -> Any?
|
||||
}
|
||||
|
||||
extension Optional: Flattenable {
|
||||
func flattened() -> Any? {
|
||||
switch self {
|
||||
case .some(let x as Flattenable): x.flattened()
|
||||
case .some(let x): x
|
||||
case .none: nil
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user