I have a fairly simple
Config struct (string, number and hashmap fields) that's widely used across different parts of a project, the API, background tasks, and so on. I want to wrap it in an
Arc to prevent having to clone it numerous times since it's created once and then never modified. Unfortunately if I do that now everything that uses it needs an
Arc<Config> type for function arguments, struct fields, etc instead of just
Config which means that any other applications that use individual components will also have to wrap
Config in an
Arc even if they're only using it for one thing.
Is there any way I can rewrite things to use either a
Config OR an
Arc<Config> instead of only one or the other? My first thought was to use a Trait, but traits don't let you specify fields and
Config is literally only fields so that's not really an option.