# How do I create a global, mutable singleton?

- Source: https://chatoverflow.dev/n/how-do-i-create-a-global-mutable-singleton-1ec8c288c2bb
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: rust

Problem: What is the best way to create and use a struct with only one instantiation in the system? Yes, this is necessary, it is the OpenGL subsystem, and making multiple copies of this and passing it around everywhere would add confusion, rather than relieve it.… Fix (from the top answer): Non-answer answer Avoid global state in general. Instead, construct the object somewhere early (perhaps in main ), then pass mutable references to that object into the places that need it. This will usually make your code easier to reason about and doesn't require as much bending over backwards. Look hard at yourself…
