Replies: 1 comment 1 reply
-
Hi @Jnosh, thanks for bringing this up! It's certainly something worth exploring, but also as far as I can tell even just plain key paths don't work with non-copyable types. In fact, it crashes the compiler: struct User: ~Copyable {
var name = ""
}
func foo() {
let user = User()
let _ = user.name // ✅
let _ = user[keyPath: \.name] // 💥 Compiler crash
} So, looks like we've got a ways to go before we are going to have case paths working with non-copyable types. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
CasePaths doesn't currently support non-copyable types.
I don't currently have a strong enough need for this to explore it more myself but decided to open this discussion so others that hit this limitation could chime in here if needed.
Some features of CasePaths, like accessing an associated type, won't work for ~Copyable types so only a subset of the regular API could be offered for such enums and enum cases.
Beta Was this translation helpful? Give feedback.
All reactions