namespace Brutal.VulkanApi.Abstractions; /// /// Provides extension methods for IDisposable objects. /// public static class DisposableExtensions { /// /// Disposes each element in the provided span. /// /// The type of IDisposable objects. /// The span of IDisposable objects to dispose. public static void Dispose(this Span inObjects) where T : IDisposable { foreach (var obj in inObjects) obj.Dispose(); } /// /// Disposes each element in the provided array. /// /// The type of IDisposable objects. /// The array of IDisposable objects to dispose. public static void Dispose(this T[] inObjects) where T : IDisposable { foreach (var obj in inObjects) obj.Dispose(); } /// /// Disposes each element in the provided enumerable collection. /// /// The type of IDisposable objects. /// The enumerable collection of IDisposable objects to dispose. public static void Destroy(this IEnumerable inObjects) where T : IDisposable { using var enumerator = inObjects.GetEnumerator(); while (enumerator.MoveNext()) enumerator.Current.Dispose(); } }