Files
sing-box-for-apple/ApplicationLibrary/Views/Abstract/Binding+Unwrap.swift
T
2023-07-15 15:03:45 +08:00

12 lines
270 B
Swift

import SwiftUI
public extension Binding {
func unwrapped<T>(_ defaultValue: T) -> Binding<T> where Value == T? {
Binding<T>(get: {
wrappedValue ?? defaultValue
}, set: { newValue in
wrappedValue = newValue
})
}
}