Mara Bos Profile picture
Rust dev, Electronics engineer, Founder/CTO of Fusion Engineering, @rustlang Library team lead, ADHD, Polyamorous, Lesbian, She/Her
May 16 • 4 tweets • 1 min read
🦀 As of Rust 1.62 (going into beta this week), std::sync::Mutex, RwLock, and Condvar no longer do any allocations on Linux. 🎉

Benchmarking locks is extremely tricky, as their performance depends heavily on the exact use case, but there are very noticable differences: A table showing before and after times of three tests.  test std's Mutex basically used to contain a Pin<Box<pthread_mutex_t>>, where the pinned Box was only necessary because pthread_mutex_t is not guaranteed movable. The new Mutex no longer uses pthread, and instead directly uses the futex syscall, making it smaller and more efficient.
Jan 13 • 11 tweets • 5 min read
🦀✨ @rustlang 1.58.0 was released just now!

blog.rust-lang.org/2022/01/13/Rus…

As usual, a thread to highlight some of the new features:

1/11 First, a feature we've all been waiting for: Format argument capturing!

let name = "world";
println!("Hello {name}!");

For now, this only works with identifiers, not with more complicated expressions. E.g. `println!("{a.f() + 10}")` does not work.

2/11

Dec 2, 2021 • 11 tweets • 5 min read
🦀✨ @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 const fn f<T>() {     assert!(std::mem::size_of::<T>() < 4);error[E0080]: evaluation of constant value failed  --> src/m
Oct 21, 2021 • 17 tweets • 7 min read
A few hours ago, @rustlang 1.56 was released! 🦀

This version ships with the new edition: Rust 2021! 🐊✨🎊

There's quite a few new features in the new version and edition:

1/17 Starting today, `cargo new` will use `edition = "2021"`. You can migrate your 2018 crates with `cargo fix --edition`.

These are all the edition changes:

1. `array.into_iter()` now iterates by value, instead of giving references.

(See for details.)

2/17 for (i, x) in [1, 2, 3].into_iter().enumerate() {        //
Sep 9, 2021 • 11 tweets • 5 min read
🦀 Happy new Rust! 🎆

Just now, @rustlang 1.55 was released, shipping with some small but very nice improvements.

blog.rust-lang.org/2021/09/09/Rus…

A thread: 🦀 1. Half-open ranges in patterns.

Next to `start..=end`, you can now also use `start..` as a pattern to match on: fn f(x: u32) {     match x ...
May 6, 2021 • 10 tweets • 5 min read
The new stable version of @rustlang, Rust 1.52, was released just now! 🦀🎉

This release contains quite a few new small but significant features.

A thread.

1/10

blog.rust-lang.org/2021/05/06/Rus… My favourite new addition is `str::split_once`.

We already had str::split and str::splitn, which result in an iterator. But when parsing something simple, you often want to split something exactly once. For example, to parse a string containing `key=value`.

2/10   let s = "hello=world";   let (key, val) = s.spliScreenshot of the split_once and rsplit_once documentation.
Apr 24, 2021 • 6 tweets • 4 min read
I just approved the PR for a very exciting addition to @rustlang 1.53: IntoIterator for arrays 🎉🦀

Before this change, only references to arrays implemented IntoIterator, which meant you could iterate over &[1,2,3] and &mut [1,2,3], but not over [1,2,3] directly.

1/6 error[E0277]: `[{integer}; 3]` is not an iterator  borrow thfor e in [1, 2, 3] { // Works in 1.53!     println!("{} The reason we didn't add it sooner was backwards compatibility. `array.into_iter()` already compiles today, because of the way methods get resolved in Rust. This implicitly calls `(&array).into_iter()`. Adding the trait implementation would change the meaning and break code.

2/6 for e in [1, 2, 3].into_iter() {     // Surprise: `e` is a r
Apr 22, 2021 • 17 tweets • 6 min read
Lots of new standard library additions will become stable in @rustlang 1.53. 🦀🎉

Thread: 1. Duration::ZERO, Duration::is_zero(), Duration::MAX pub const ZERO: Duration  A...