3 ms·
In rust you can also do something like: let (x, y) = { ... (some code that only serves to create x and y) }; I really really like that feature
by sophacles 4y ago
In rust you can also do something like:
let (x, y) = {
... (some code that only serves to create x and y)
};
I really really like that feature for controlling scoping - it's like a single use function that doesn't involve so much navigation.
Other languages allow similar constructs with blocks too. For ones that allow inline lambdas, you can also get similar results by defining and immediately calling the function.