this post was submitted on 16 Aug 2023
37 points (97.4% liked)

Rust

6055 readers
162 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
top 3 comments
sorted by: hot top controversial new old
[โ€“] [email protected] 4 points 1 year ago (1 children)

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

[โ€“] [email protected] 3 points 1 year ago (1 children)
[โ€“] Barbacamanitu 2 points 1 year ago

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