# A final proposal for await syntax

**URL:** <https://internals.rust-lang.org/t/a-final-proposal-for-await-syntax/10021>\
**Category:** language design\
**Created:** [May 6, 2019, 2:36pm UTC](https://internals.rust-lang.org/t/a-final-proposal-for-await-syntax/10021 "2019-05-06T14:36:19Z")\
**Posts on this page:** 1\
**Showing post:** 213

<div class="post-metadata">

**Author:** ![Pauan](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/pauan/32/3006_2.png) [@Pauan](https://internals.rust-lang.org/u/Pauan)\
**Post date:** [May 13, 2019, 2:15am UTC](https://internals.rust-lang.org/t/a-final-proposal-for-await-syntax/10021/213 "2019-05-13T02:15:49Z")

</div>

> [@197g](#):
>
> Using `deref` seems to break down when we are interested in by-value semantics my above example.

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

> <https://github.com/rust-lang/rfcs/pull/2439>
>
> \[Rendered\](https://github.com/alercah/rfcs/blob/deref-move/text/0000-deref-move.…md)
> 
> Part of #997.

> <https://github.com/rust-lang/rfcs/issues/997>
>
> It is clear that there is a need for the ability to move out of smart pointers a…nd indexable things (\`DerefMove\`, \`IndexMove\`). The other frequently desired option is to \`IndexSet\`, which would be a special-cased version for indexing in this situation:
> 
> \`\`\`
> map\[key\] = value
> \`\`\`
> 
> currently, this is handled via \`IndexMut\`, but that is sub-optimal, because if the \`key\` is not already part of the \`map\`, the result is a panic.
> \### Basic plan
> 
> DerefMove/IndexMove/IndexSet should layer on top of the traits we have now. One needs to be careful here because of subtle interactions with autoref and so forth. 
> \### Postponed RFCs
> \- https://github.com/rust-lang/rfcs/pull/178
> \- https://github.com/rust-lang/rfcs/pull/159
> \- https://github.com/rust-lang/rfcs/pull/1129 (\`map\[key\] = value\`)

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:

```js
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](https://en.wikipedia.org/wiki/Property_%28programming%29). They even have [a principle for it](https://en.wikipedia.org/wiki/Uniform_access_principle). It isn't unusual at all for fields/properties to have magic behavior, or to run user code.

---

_[View the full topic](https://internals.rust-lang.org/t/a-final-proposal-for-await-syntax/10021)._
