In Rust 1.73.0, it'll be easier to use thread_local Cells and RefCells

https://hachyderm.io/@Mara/110894448573113545

37 points · 3 comments · view on lemmy.world

3 Comments

spez@sh.itjust.works · 4 pts · 3y (2 replies)

Toot :

🦀 In #rustlang 1.73.0 (to be released on October 5th), it'll be easier to use thread_local Cells and RefCells: the set, get, replace, take, and with_borrow[_mut] methods will be directly available on the thread local, removing the need for the usual .with(|_| …) pattern: 1/2

The new .set() method can be more efficient than .with(|x| x.set()), because it skips the step where the first call to with initializes the variable. The option to skip the default initializer can be very useful in some situations:

2/2

darcy@sh.itjust.works · 3 pts · 3y (1 reply)

spez?

Barbacamanitu@lemmy.world · 2 pts · 3y

Lol not a great name choice. Wish I would have thought of it though.