]> git.r.bdr.sh - rbdr/map/blob - Map/Extensions/Binding+unwrap.swift
3498cc377dc08d156aa52e75b1b38c1d2c92d88f
[rbdr/map] / Map / Extensions / Binding+unwrap.swift
1 import SwiftUI
2
3 extension Binding {
4 init(_ source: Binding<Value?>, _ defaultValue: Value) {
5 // Ensure a non-nil value in `source`.
6 if source.wrappedValue == nil {
7 source.wrappedValue = defaultValue
8 }
9 // Unsafe unwrap because *we* know it's non-nil now.
10 self.init(source)!
11 }
12 }