pointfreeco / swift-case-paths

🧰 Case paths extends the key path hierarchy to enum cases.
https://www.pointfree.co/collections/enums-and-structs/case-paths
MIT License
904 stars 105 forks source link

Allow writability when chaining into a dynamic case #150

Closed stephencelis closed 6 months ago

stephencelis commented 6 months ago

While we should prohibit directly assigning a value through a case:

state.loggedIn = User(name: "Blob")  // 🛑

We can allow optional-chaining into a case's sub-value via an overload and some disfavoring:

state.loggedIn?.name = "Blob"  // ✅