4 ms·
How would rust help in this situation? What alternate design is rust enabling that would be different?
by winstonewert 10y ago
How would rust help in this situation? What alternate design is rust enabling that would be different?
- dbaupp 10y agoUse an `enum` like Cow[1] that allows passing around static strings along with dynamic strings, as well as interior pointers: the compiler can check that things don't get invalidated and the enum makes it trivial to deallocate things correctly (in fact, it's all done automatically by the compiler), so a more aggressive design can be used, no need to defensively copy the strings. [1]: https://doc.rust-lang.org/std/borrow/enum.Cow.html https://doc.rust-lang.org/std/borrow/enum.Cow.html
- winstonewert 10y agoOh, wow, thanks. I finally understand what the purpose of Cow is!