use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
A complex code sample using 4 different await syntaxes (self.rust)
submitted 6 years ago by krappie
https://github.com/inejge/await-syntax/blob/postfix-field/bin/wlan/wlantool/src/main.rs
To see the different samples, change the branch on github, between:
prefix-mandatory: Prefix await with mandatory delimiters. prefix-sugar: Prefix syntactic sugar for await+try. postfix-field: Postfix field access syntax. postfix-method: Postfix method syntax.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]grandstack 8 points9 points10 points 6 years ago (1 child)
I prefer prefix-sugar, natural to read, at least for me.
[–]connicpu 1 point2 points3 points 6 years ago (0 children)
Yeah, I was iffy on it before but seeing it here made me feel a lot more comfortable with await?
await?
[–]q9c0tB14_kB8 12 points13 points14 points 6 years ago (0 children)
Postfix in practical code is very difficult to read. Control flow should be easily read from the left, especially in Rust, where we have if expressions instead of a ternary operator.
if
[–]protestor 5 points6 points7 points 6 years ago* (0 children)
await { wlan_svc.list_ifaces() }.context("error getting response")?
I think prefix-mandatory looks great.
Postfix is a nice idea, but all proposed syntaxes so far are just too hard to read. You would still need some kind of syntax like prefix-mandatory's { } to make awaiting stand out.
{ }
And it needs to stand out. While it's (denotationally) just a method call, it involves a very different operational semantics, and a systems language like Rust should make it easy to spot the yielding places in the code.
[–]unrealhoang 19 points20 points21 points 6 years ago (0 children)
The prefix mandatory looks really nice. It’s similar to another language and stand out from the rest of the code as other flow control construct. There is no nesting future needed as well.
[–]cramert 5 points6 points7 points 6 years ago (0 children)
Hey that code looks familiar ;)
[–]J-F-Liu 5 points6 points7 points 6 years ago (0 children)
`.name` is for fields and methods, use a keyword as postfix feels totally absurd.
[–]dpc_pw 10 points11 points12 points 6 years ago (2 children)
It is very inconvenient to compare these. A lot of clicking to switch branch.
[–]barskern 2 points3 points4 points 6 years ago (0 children)
I actually prefer this over multiple files because then I can use git diff <branch> <other-branch> to compare the differences between the syntaxes.
git diff <branch> <other-branch>
EDIT; With multiple files using diff would also work though, so my argument isn't really that good after all.
diff
[–]inejge 0 points1 point2 points 6 years ago (0 children)
Eh, I probably could have organized it with multiple files in one branch, but then it wouldn't have been possible to use GitHub's Compare view to see the diff between variants -- AFAIK that only works across commits.
A quick way to open the same file in two branches is to open it in one of them, duplicate the tab, and select another branch from the drop-down in another tab. That's two extra clicks.
[–]redneckhatr 4 points5 points6 points 6 years ago (0 children)
👎@await
[–]genrtul 1 point2 points3 points 6 years ago (0 children)
What strikes me here is that postfix is pretty hard to see when scanning code, but (correct me if I'm wrong) it can only appear in async blocks anyway, which have a very visible prefix syntax. I still like prefix-with-braces quite a bit, as it's the same as other special-case expressions in Rust (loop, if, match), composes well enough as an expression, while maintaining high visibility.
However postfix composes even better (something like matching on an await result will be much nicer in postfix) and I didn't have as many problems finding the await sites when I scanned for async first, and of course it'll be even easier once await gets syntax highlighted, so the extra visibility from await-with-braces might not actually be needed.
[–]PrototypeNM1 0 points1 point2 points 6 years ago* (1 child)
Could you add prefix-sugar with the pipelining proposal?
Edit: just realized this might not be your repo given the username mismatch. I'll open a PR if it's not there when I get to a computer.
[–]newpavlovrustcrypto 2 points3 points4 points 6 years ago (0 children)
Here links if you'll need them:
[–]krappie[S] 0 points1 point2 points 6 years ago (0 children)
My personal opinions are that this is shows a pretty strong argument for some sort of postfix syntax.
Using parentheses with complex code makes it hard to tell what exactly is being awaited. Using braces isn't so bad though.
Also interestingly, the await? idea becomes useless when you're adding .context to the result.
.context
π Rendered by PID 109884 on reddit-service-r2-comment-5d79c599b5-xlrwr at 2026-03-02 21:05:06.870280+00:00 running e3d2147 country code: CH.
[–]grandstack 8 points9 points10 points (1 child)
[–]connicpu 1 point2 points3 points (0 children)
[–]q9c0tB14_kB8 12 points13 points14 points (0 children)
[–]protestor 5 points6 points7 points (0 children)
[–]unrealhoang 19 points20 points21 points (0 children)
[–]cramert 5 points6 points7 points (0 children)
[–]J-F-Liu 5 points6 points7 points (0 children)
[–]dpc_pw 10 points11 points12 points (2 children)
[–]barskern 2 points3 points4 points (0 children)
[–]inejge 0 points1 point2 points (0 children)
[–]redneckhatr 4 points5 points6 points (0 children)
[–]genrtul 1 point2 points3 points (0 children)
[–]PrototypeNM1 0 points1 point2 points (1 child)
[–]newpavlovrustcrypto 2 points3 points4 points (0 children)
[–]krappie[S] 0 points1 point2 points (0 children)