Rust In Paris started with Waffle @wffl presenting the Little Rust Delights. #RustLang #RustInParis
Waffle usually sees the broken parts of Rust, and wanted to share the nice things about Rust.
#RustInParis
The first thing is the collect trait, which allows collecting into many collections. But also unexpected things like tuples, Option or Result. One can even collect a unit () from an iterator. It allows composition with other Result<(), E> to implement a custom `try_for_each`.
#RustInParis
It's possible to include a file with `include_str!` directly into the documentation of item. For example, the full README of the project can be included in a crate doc that way to prevent duplication.
#RustInParis
In Rust, a loop is infinite, so its type is ! aka the never type. If the loop {...} has a break, the type changes to the unit type (). And break can even take a value, and its type becomes the type of the loop
#RustLang #RustInParis
In addition, loops can have labels, which is useful when nested. And similarly, break takes a label just before its value.
#RustInParis
Patterns are a powerful feature of Rust. They are known to be useful in match. But they can be used everywhere, as long as they are exhaustive: in let assignments, for loops, function arguments...
#RustInParis

In some cases, for example when implementing a trait, it might be desirable to implement a Result, when we know that the error will never happen. The standard library has std::convert::Infallible for that. It's there possible to not use .unwrap() but let Ok(v) = result instead, which gives a stack guarantee. In this case, Infallible is not special, and any uninhabited type can be used for that, even the never type: ! .

#RustInParis

Rust allows let without assignment, so a variable can be assigned only once later (mutation is still disallowed). This can be used to escape blocks, or to make multiple assignements in blocks more readable. Waffle also showed a much cooler trick to prevent using Trait objects, but for that you'll have to watch the video!

#RustLang #RustInParis

@Aissen that's what happened to me after working on Clippy for a while lol, "how can this thing be so broken all the time". Obviously, when I took a step back from the issue tracker and used the thing normally for a bit, I remembered right away that, for the majority of time and use cases, it works pretty much flawlessly.