Add 'remove' method to Resources.
thorjelly opened this issue · comments
It seems to be desirable to take ownership again of a resource, without needing to wrap that resource in an Option, by removing it from Resources. For example, in my case, gfx::Device requires to be passed ownership of some things to destroy them, such as buffers, which I am using inside of a Resource. It is possible to wrap these in Option and take() them, but because during dispatch these should never be taken and never be None, it seems, though a very minor inconvenience, an unfortunate solution.
Thanks for the issue!
The reasons I remember for not doing this initially:
- registration in
MetaTable
s - we'd need a way to unregister them properly - resource mappings for scripting - we also need to deal with removed resources
- (unsafe) storing of a
TrustCell
is more complex; we can't rely that lifetimes resources == lifetime resource (note: this is not used anywhere, but I didn't know if I might want to do that at some point)
I'm inclined to add such a method, but it needs some more thinking.