// Copyright © WireMock.Net namespace System.Buffers; internal sealed class Lease(ArrayPool pool, int length) : IDisposable { public T[] Rented { get; } = pool.Rent(length); public static implicit operator T[](Lease lease) => lease.Rented; public void Dispose() { pool.Return(Rented, true); } } internal static class ArrayPoolExtensions { public static Lease Lease(this ArrayPool source, int length) => new(source, length); }