🦀✨ @rustlang 1.57.0 was released just moments ago!
blog.rust-lang.org/2021/12/02/Rus…
As usual, a thread to highlight some of the new features:
1/11
1. panic!() and assert!() can now be used in const fns.
Any formatting other than panic!("..") and panic!("{}", some_str) is not accepted though, because formatting is not const (yet!).
2/11
2. Many functions in the standard library have been marked as #[must_use], to warn you when just calling the function without using its result is most likely a mistake.
(See the full list here: github.com/rust-lang/rust…)
3/11
3. Iterator::map_while.
Basically a combination of map and take_while: Your closure is used to map each item, but can return None when it's done.
4/11
4. Custom Cargo profiles!
Next to the standard Cargo profiles such as `release`, you can now define your own profiles with custom settings:
5/11
5. A dot or question mark after a braced macro invocation is no longer an error:
m! { .. }.method(); // ok!
m! { .. }?; // ok!
See
6/11
6. Fallible allocation.
Vec, String, VecDeque, HashMap and HashSet now have a .try_reserve() method. This method is similar to .reserve(), except it doesn't panic/abort when it was unable to allocate memory.
7/11
7. Vec::leak no longer reallocates.
Vec::leak used to shrink the capacity before leaking the data, which might involve a reallocation. The behaviour is now changed to always leak the current allocation, without shrinking/reallocating first.
8/11
8. std::hint::unreachable_unchecked is now const.
In *const* context, it'll result in a compiler error when reached, not in undefined behaviour like it would at runtime.
9/11
9. There's a few new tier 3 targets:
- armv6k-nintendo-3ds
- armv7-unknown-linux-uclibceabihf
- m68k-unknown-linux-gnu
- aarch64-kmc-solid_asp3
- armv7a-kmc-solid_asp3-eabi
- armv7a-kmc-solid_asp3-eabihf
See doc.rust-lang.org/nightly/rustc/…
10/11
And that's all I wanted to highlight in this thread!
For a more complete list of changes in Rust 1.57, check the release notes:
Rust: github.com/rust-lang/rust…
Cargo: github.com/rust-lang/carg…
Clippy: github.com/rust-lang/rust…
Enjoy!
11/11
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.