Here’s a little idiom that I haven’t really seen discussed anywhere, that I think makes Rust code much cleaner and more robust. I don’t know if there’s an actual name for this idiom; I’m calling it the “block pattern” for lack of a better word. I find myself reaching for it frequently in code, and I think other Rust code could become cleaner if it followed this pattern. If there’s an existing name for this, please let me know! The pattern comes from blocks in Rust being valid expressions.
John Nunley
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with John
Contact John, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack