mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
21 lines
726 B
C#
21 lines
726 B
C#
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;
|
|
}
|
|
}
|
|
}
|