I'm trying to write a "quick and dirty" simulation of a random process. My main concern is writing the logic of the process itself, which is relatively complex (at least for my level of Rust knowledge...)
I know it's not good practice, but I want to avoid having to pass round a RNG through my various functions, just so that I have it available in the low-level functions that implement the randomness in my model. In other languages I've worked with, I'd use a global variable - with a certain amount of distaste, and promises to "fix it later", but in the interests of focusing on the important aspects of the problem.
I've seen a lot of dire warnings about static mut
, so I assume that's not what I should use here. The trouble is, most of those warnings suggest alternatives like interior mutability, which is way beyond my level of understanding, and not something I want to get sucked into, just to get my little simulation to work.
Is there a good solution to this problem? I'm aware of (and in agreement with) the arguments saying that global state is bad. But not being able to focus on my actual code is worse, in this case. I would be perfectly happy with some sort of "you don't need to understand this" magic incantation for now - heck, one day, when I do have the time, I'd probably take the time to understand such a solution (and in the process learn more about Rust ), but for now I just want to get back to my actual code...