Re:Rust is more than safety
by dbaupp on Wednesday December 28, 2016 @05:56PM
(#13274390)
The equivalent of a function returning Result<T, E> in Rust would be returning something like unique_ptr<ResultBaseClass<T,E>> because the two subclasses have different sizes and thus can't be returned directly (or else one will be object slicing). The struct version stores everything inline from the start (it has a single static size) and so can be returned without needing a pointer.
[ Parent
| on HN ]
Re:Rust is more than safety
by lacampbell on Wednesday December 28, 2016 @07:38PM
(#13274895)
My C++ skills have atrophied worse than i thought - I completely forgot you can't return an abstract class by value.