this post was submitted on 25 Dec 2025
21 points (95.7% liked)
Rust
7778 readers
3 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
NGL that block pattern thing is something I never really noticed but it makes a lot of sense. The messy way to do it in C++ would be with a lambda that you then just evaluate, but being about to avoid that and instead using standard scoping syntax for the same thing neat. I'm pretty sure I've even done this before without even thinking about it.
And if you put all of the definitions you need right at the top it's super easy to split out into a function if/when you need it elsewhere