No seriously, I am a rustacean too, but please stop telling everyone to Rewrite everything in Rust (even if its only a joke), its becoming slightly annoying
Rust binaries are optimized to be fast (by default, fast != small), this [0] explains pretty well why, and min-sized also has many optimizations [1].
> and compiles slow
You can have a very slow compiler with all the optimizations and safety checks, or a fast one which doesn't. This however doesn't mean there is no room for improvement.
One thing that can definitely improved on is how cargo manages dependencies, I am tired of each of my project's /target directory using >2GB of disk space, there at least should be some kind of opt-in global cache.
I am also worried about dependencies going in the same direction as the JS ecosystem, many of my projects only have 3-5 top level dependencies, but I end up downloading hundreds. A few are only compile-time, but this makes auditing very difficult and does make compile times a lot longer.
In rust you can use these almost everywhere in place of an expression (if statements, while loops, in function arguments, etc). It can sometimes make code a bit unreadable to some people, but its still a cool feature imo.
Conveniently in Rust because a block is an expression it lets you "convert" a statement (or sequence thereof) into an expression.
To be used sparingly, but very useful when it applies e.g. in the precise capture clause pattern, or for non-trivial object initialisation (as Rust doesn't have many literals or literal-ish macros).
Here's one notable use that I doubt many are familiar with:
let iter = some_iterator_expression;
{iter}.nth(2)
For some reason, nth takes &mut self instead of self (note that T: Iterator => &mut T: Iterator<Item=T::Item> so there was no need for this in the API design to support having access to the iterator after exhaustion; it was a mistake). So if you tried to use it like iter.nth(2) with the non-mut binding, that would fail. But {iter} forces iter to be moved - unlike (iter) which would not. Then iter becomes a temporary and we're free to call a &mut self method on it.
In general: {expression} turns a place expression into a value expression, i.e. forcing the place to be moved from.
Interesting. I don't see any use for it (since adding `mut` to the `let iter` declaration sounds less annoying than dropping `iter` altogether) but I learned something nonetheless, thank you.
Probably off-topic, but I recently made the stupid decision of learning dvorak while I had to get some important work done.
I am currently at: 1) I don't type dvorak fast enough which really reduces my motivation, but I'm getting faster pretty quickly 2) My qwerty typing skills have gotten even worse, I look a bit stupid when I try to fix problems on other computers at ~15 WPM.
Generally I don't regret starting to type dvorak, I just wish I had done it another time where typing slowly doesn't affect me as much.
I started learning Dvorak my first semester of college (many years ago). I sort of "regretted" it for a while, especially when I needed to write a paper before a deadline. But I pushed through and am glad for it.