language-rust
language-rust copied to clipboard
Add support for unquotation.
This set of patches adds in the ability to do unquotation in a variety of places:
- As identifiers:
[item| fn $$foo(x: u8) -> u8 { return 0; } |] - As expressions:
[expr| 1 + $$(one) |] - As statements: ```[stmt| if x > 3 { $${something} } |]
- As a series of statements:
[stmt| if x > 3 { $@{somethings} } |]
... and so on. The syntax was not a particularly well-thought-out choice, and should be pretty easy to change if you don't like it. Right now, this only supports identifiers as the splice (e.g., $$(foo) but not $$(foo 4)); it wasn't super clear how to do this easily.
I'll give this a thorough review this weekend - but I just wanted to quickly say thanks, because I've wanted this for a long time, and this PR looks like a splendid way of dealing with the problem!
Hello! Just wanted to check in on this. There's a few missing things, still, like the ability to unquote-splice constant arrays, but mostly this seems to be working out for me in a little personal project. I'd be curious if you have any feedback, or if there's an easier way to make this all work.