▲ | tialaramex 4 days ago | |
Sure. Notice std::unique_ptr<T> is roughly equivalent to Rust's Option<Box<T>> The C++ "move" is basically Rust's core::mem::take - we don't just move the T from inside our box, we have to also replace it, in this case with the default, None, and in C++ our std::unique_ptr now has no object inside it. But while Rust can carefully move things which don't have a default, C++ has to have some "hollow" moved-from state because it doesn't have destructive move. |