Created
September 23, 2022 11:53
-
-
Save NikolaiRuhe/456eb626d494fc26a3e9077b7fe5fee9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Binding where Value: MutableCollection, Value.Element: Identifiable { | |
subscript(_ id: Value.Element.ID) -> Binding<Value.Element> { | |
let index = wrappedValue.firstIndex { $0.id == id } | |
guard let index else { | |
fatalError("id not found: \(id)") | |
} | |
return self[index] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment