This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit b578433e37

View file

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