Jenna Magius is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.

You: "Rust is bad for video games because video games are basically composed entirely of global state and Rust is very bad at global state."

Me, wise: "Actually, Rust handles global state basically fine, you just have to know a lot of stuff that the Rust book doesn't teach you about."

The idea I'm trying to convey does not actually fit in that meme format.

Also by "you" I mean "me, about a month ago"

(The thing you need to know is: use thread_local! a lot, or const-function constructed mutexes out of the parking_lot crate.)

Jenna Magius @jennamagius

Or, the thing you need to know at a higher level is:

The way Mutex and RefCell work is that you can start with an immutable reference to the outside and wind up with a mutable reference to the inside.

Also, you can call MutexGuard.deref_mut() explicitly to get an actual tier 1 &mut InnerType, which you can pass to functions.

· Web · 0 · 0