using System.Diagnostics; namespace Brutal.Localization.FixedBuffers; public static class TryWriteInterpolatedStringHandlerExtensions { extension(MemoryExtensions.TryWriteInterpolatedStringHandler handler) { /// /// Returns the number of elements currently written to a TryWriteInterpolatedStringHandler. /// /// The number of elements written. public int ElementsWritten() { var shouldBeTrue = MemoryExtensions.TryWrite([], ref handler, out var elementsWritten); Debug.Assert(shouldBeTrue, "TryWrite with empty collection should always succeed."); return elementsWritten; } } }