News for hackers. Stuff that matters.
Re:Why asynchronous Rust doesn't work by pornel on Saturday November 13, 2021 @08:57AM (#29209724)
Rust has stopped depending on closures for async when it moved from experimental futures library to built-in async/await. Rust now easily supports mutable and temporary references in async blocks and across await points.

Rust still doesn't support use-after-free, so you can't reference a temporary object and use it in another thread that will outlive it :)

In TFA the second do_work_and_then() example doesn't compile, because it has a UAF vulnerability that borrow checker has detected and prevented.

Re:Why asynchronous Rust doesn't work by ipodopt on Saturday November 13, 2021 @12:42PM (#29211596)
You can't do that using anything here?

https://doc.rust-lang.org/std/mem/index.html

Genuine question, I don't mess around with memory typically.

Re:Why asynchronous Rust doesn't work by pornel on Sunday November 14, 2021 @03:47PM (#29220500)
mem::forget() is not crashy like free(). It merely prevents destructors from being run (e.g. you could do the same by storing the value in a global variable). It's a safe method, subject to usual safety checks.

You can use an `unsafe {}` block to call literally libc::free(), or dereference a random raw C pointer, or do something else crashy. However, when talking about Rust's safety rules it's usually assumed we're not talking about code bypassing these rules on purpose.

Re:Why asynchronous Rust doesn't work by eximius on Saturday November 13, 2021 @01:58PM (#29212280)
forget takes owned values. So you wouldn't have a handle to them to use after.