A final proposal for await syntax

Actually, there are proposals for implementing a DerefMove (and IndexMove) traits:

So if anything, it seems like . will probably have even more magic behavior in the future (regardless of what happens with await)

The simple fact is that . has always been magic in Rust (and for good reason), this isn't unusual.

And other languages like JavaScript have getters/setters which allow you to run arbitrary code when a property is accessed or set:

class Foo {
    get bar() {
        console.log("Getting bar");
        return 5;
    }

    set bar(value) {
        console.log("Setting bar to", value);
    }
}

let x = new Foo();
x.bar;
x.bar = 10;

Many other (popular) languages can also do this. They even have a principle for it. It isn't unusual at all for fields/properties to have magic behavior, or to run user code.

4 Likes