import SwiftUI extension Binding where Value == Bool { init(bindingOptional: Binding) { self.init( get: { bindingOptional.wrappedValue != nil }, set: { newValue in guard newValue == false else { return } /// We only handle `false` booleans to set our optional to `nil` /// as we can't handle `true` for restoring the previous value. bindingOptional.wrappedValue = nil } ) } } extension Binding { func mappedToBool() -> Binding where Value == Wrapped? { Binding(bindingOptional: self) } }