4 ms·
Ever tried changing an owned field in a struct to a borrowed one with lifetimes? Be prepared to change not only the struct and its fields but also everything el
by jdemler 9y ago
Ever tried changing an owned field in a struct to a borrowed one with lifetimes?
Be prepared to change not only the struct and its fields but also everything else where it appears.
Yes, the compiler will catch your mistakes, but no, it's not something I love.
- tormeh 9y agoI think the Rust devs like C++'s abstraction level. Rust is about the same (more modern), it just catches your errors. I don't think it's possible to make Rust as ergonomic as Python, but I do think it's possible to move a little in that direction without losing Rust's strengths.
- pjmlp 9y agoActually that is the goal of the other languages, Swift, Haskell, OCaml, ParaSail... Influenced by Rust's success bringing affine types into mainstream. To keep using automatic memory management as their default way of managing memory, while offering some escape hatches based on affine types for low level optimizations.
- danieldk 9y agoIndeed, this is painful. Plus that lifetimes tend to percolate through the codebase. This is logical and necessary, if a struct is bound to a lifetime, then another struct holding this struct is also bound to that lifetime. It can be painful regardless ;).
- steveklabnik 9y agoI hear you. It’s an important thing though; it will get slightly easier soon...