Extract Payload for enum cases having associated value

Like below?

let result: Result<S, F> = ...
result.success // does not compile
result.failure // does not compile
let success = result[keypath: \.success]) // S?
let failure = result[keypath: \.failure]) // F?

This would be an interesting twist of Automatically derive properties for enum cases - #5 by stephencelis. No properties. Only key paths. But this is another pitch.

1 Like