# Possible postfix macro use case: \`.unwrap\_dbg!(...)\`

**URL:** <https://internals.rust-lang.org/t/possible-postfix-macro-use-case-unwrap-dbg/14285>\
**Category:** language design\
**Created:** [March 17, 2021, 2:41pm UTC](https://internals.rust-lang.org/t/possible-postfix-macro-use-case-unwrap-dbg/14285 "2021-03-17T14:41:44Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [March 17, 2021, 9:24pm UTC](https://internals.rust-lang.org/t/possible-postfix-macro-use-case-unwrap-dbg/14285/5 "2021-03-17T21:24:38Z")

</div>

I think most people in favor of postfix macros have converged on the idea that postfix macros act like functions with respect to how it treats the receiver.

That is, conceptually, postfix macros would have a `$self` capture, and that captures the name of a temporary binding which the receiver is bound to. Example (using arbitrarily bad declaration syntax):

```rust
macro $self.unwrap_dbg!( $($tts:tt)* ) => { ... }

fallible(foo, bar).unwrap_dbg!(foo, bar);

// is semantically similar to

macro unwrap_dbg!( $self:ident, $($tts:tt)* ) => { ... }

match fallible(foo, bar) {
    __receiver => unwrap_dbg!(__receiver, foo, bar),
};

```

Anything else breaks the sanctity of "what code does" outside a macro invocation. Some trickery might be required such that `$self` refers to a temporary with the same semantics as if it hadn't been passed through a `match` rebind, but doing so seems feasible, and I plan to [propose said semantics separately as a new capture type for macros](https://internals.rust-lang.org/t/pre-rfc-a-value-matcher-for-macro-rules/14357).

---

_[View the full topic](https://internals.rust-lang.org/t/possible-postfix-macro-use-case-unwrap-dbg/14285)._
