A final proposal for await syntax

Here’s an even better example:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c56255bf09cab8bd804d6351dbab7ae4

use std::ops::Deref;

struct Foo {
    value: i32,
}

struct Bar {
    foo: Foo,
}

impl Deref for Bar {
    type Target = Foo;
    
    fn deref(&self) -> &Self::Target {
        println!("Firing the nukes!");
        &self.foo
    }
}

fn main() {
    let bar = Bar {
        foo: Foo {
            value: 10,
        },
    };

    // Not a method call, but it still has side effects!
    bar.value;
}
20 Likes