3
lorentz
1y

[Rust] What are alternatives to argument drilling for something like a string interner which is technically a memory leak so it really shouldn't be global but at the same time all but a couple top level functions depend on its existence? I'm aware of context objects and that's all ChatGPT could give me as well, but I'm wondering if there's more to this problem than that.

Comments
  • 0
    These are pretty much your only two options at the moment.

    If Rust ever gets a context system, that could be solved better: https://tmandry.gitlab.io/blog/...

    If you know when the interner is no longer used, you could clear it afterwards, avoiding a memory leak while storing it in a global.
Add Comment