LenFunction.cs 451 B

123456789101112131415
  1. namespace Lua.Standard.Text;
  2. public sealed class LenFunction : LuaFunction
  3. {
  4. public override string Name => "len";
  5. public static readonly LenFunction Instance = new();
  6. protected override ValueTask<int> InvokeAsyncCore(LuaFunctionExecutionContext context, Memory<LuaValue> buffer, CancellationToken cancellationToken)
  7. {
  8. var s = context.GetArgument<string>(0);
  9. buffer.Span[0] = s.Length;
  10. return new(1);
  11. }
  12. }