Commit 85f8a26
committed
Add expression interpolation with
One annoyance I frequently run into with the `quote!` macro is that I
need to lift out all variable bindings that are being interpolated. For
example I'll often do:
let name = &foo.name;
let abi = &foo.abi;
quote! {
extern #abi fn #name() { /* ... */ }
}
but I've recently had the idea that in addition to lighteight `#name`
interpolation there's also available syntax (I believe) to support
expression interpolation as well, implemented in this PR. The above
snippet could now be rewritten as:
quote! {
extern #{foo.abi} fn #{foo.name} { /* ... */ }
}#{expr}
1 parent 44038ca commit 85f8a26
2 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
257 | 261 | | |
258 | 262 | | |
259 | 263 | | |
| |||
579 | 583 | | |
580 | 584 | | |
581 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
582 | 591 | | |
583 | 592 | | |
584 | 593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
0 commit comments