Any reason why this is not the case? Can I just add : IDisposable to the struct definition without problems?
I am looking to collect my native containers allocated outside of ECS together in a List to be disposed. Then I discovered that I cannot keep NativeHashMap in a List.
that will box the containers and make a copy of them. meaning that when you dispose, the other copies will be in an invalid state (e.g. IsCreated will still return true)
you may be better with a List<Action>and you .Add(() => container.Dispose());
that will create a closure, but if container is a field and this is a class, it will dispose the original reference