Re:Writing Pythonic Rust
by richardwhiuk on Monday May 24, 2021 @06:47PM
(#27270581)
The equivalent to the go is returning the Vec.
[ Parent
| on HN ]
Re:Writing Pythonic Rust
by throwaway894345 on Monday May 24, 2021 @09:15PM
(#27271651)
My example is probably not very good. Let’s say you have a function which implements a callback. The function takes a &str and returns some subslice. Let’s say you want to implement another function which implements that same interface, but returns the string lowercases. In Rust, you have to update the interface, you have to update all implementations, and you have to jump through hoops to avoid unnecessary cloning in the subslice case. In Go or other GC languages, there aren’t “owned” vs “unowned” types, so you don’t have to make any updates to the interface or other implementations. In a sense, GC allows us to abstract over ownership.