Comment by Inufu

1 day ago

Requiring ownership transfer gives up on one of the main selling points of Rust, being able to verify reference lifetime and safety at compile time. If we have to give up on references then a lot of Rusts complexity no longer buys us anything.

I'm not sure what you're trying to say, but the compile-time safety requirement isn't given up. It would look something like:

    self.buffer = io_read(self.buffer)?

This isn't much different than

    io_read(&mut self.buffer)?

since rust doesn't permit simultaneous access when a mutable reference is taken.

  • It means you can for example no longer do things like get multiple disjoint references into the same buffer for parallel reads/writes of independent chunks.

    Or well you can, using unsafe, Arc and Mutex - but at that point the safety guarantees aren’t much better than what I get in well designed C++.

    Don’t get me wrong, I still much prefer Rust, but I wish async and references worked together better.

    Source: I recently wrote a high-throughput RPC library in Rust (saturating > 100 Gbit NICs)