You Can't Do That: Abstracting over Ownership in Rust with Higher-Rank Type Bounds. Or Can You?
In which I'm diving into some restrictions of the Rust type system involving closures.
Hasnain says:
Bookmarking this for later re reading as I’ve run into this problem before.
“Where does this leave us? Unclear. If you go down the rabbit hole of reading about all the issues surrounding GATs and HKTBs you get a strong sense that it's better to avoid creating APIs that invole abstracting over ownership and borrowing when possible. You will run into walls and the workarounds might be ugly and hard to understand. So I guess a new thing I can recommend not to try to do: do not abstact over borrows and ownership if functions are involved (unless you really know what you are doing).”
Posted on 2022-09-11T16:53:16+0000