using System; namespace BantFlags.Data { public class PoolObject : IDisposable { public T Object { get; } private Action ReturnAction { get; } public PoolObject(T o, Action returnAction) { Object = o; ReturnAction = returnAction; } public void Dispose() { ReturnAction(Object); } public static implicit operator T(PoolObject poolObject) => poolObject.Object; } }