News for hackers. Stuff that matters.
Re:Rust – Compile Time Memory Safety by marcianx on Monday April 22, 2019 @10:47PM (#19725174)
Yes, it's completely safe and its rust equivalent is

    let x = vec![1, 2, 3];
    process(std::mem::replace(&mut x, Vec::new()));
    x.push(4);
https://doc.rust-lang.org/std/mem/fn.replace.html
Re:Rust – Compile Time Memory Safety by khuey on Tuesday April 23, 2019 @01:01AM (#19725725)
There's no guarantee that std::move moves elements out of x. (and thus no guarantee that it's equivalent to a Rust mem::replace with a new Vec) The only requirement the C++ standard imposes is that the vector is left in a "valid but unspecified state".