4 ms·
I use this all the time. It's features like these that sell Rust for me honestly; even if you wrapped your whole program in `unsafe` it would still be a massive
by andrepd 10mo ago
I use this all the time. It's features like these that sell Rust for me honestly; even if you wrapped your whole program in `unsafe` it would still be a massively better language than C++ or C.
- hu3 10mo agoMany languages use this idiom. Some popular ones even. So while it's good that Rust joined them, it's hardly a differentiator.
- andrepd 10mo agoIt's a differentiator wrt C and C++, is what I said.
- exDM69 10mo agoYes, sadly this isn't a part of standard C or C++. It is available as a language extension in Clang and GCC and widely used (e.g. by the Linux kernel). Unfortunately it is not supported by the third major compiler out there so many projects can't or don't want to use it.
- 9029 10mo agoC++ lambdas can be used to achieve a similar result, not as pretty though https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#res-lambda-init https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines... But in general I agree!
- knorker 10mo agoThe fact that you can't return from there makes for a huge difference, though,