ltheory icon indicating copy to clipboard operation
ltheory copied to clipboard

Return Result structure from the Rust code to Lua

Open HaronK opened this issue 1 year ago • 0 comments

Idea was suggested by @dgavedissian here.

It is possible now to return Result<T, E> from the impl methods with luajit_ffi attribute. In this case Rust will panic in the case of error.

But it would be better to let Lua script decide what to do in this case, so we can instead of panic return all necessary data to Lua:

struct Result_T_E {
  T ok;
  E error;
  bool is_ok;
};

We have to discuss with the script team format of this structure and in what cases we should return it and in what just panic.

HaronK avatar Jun 24 '23 10:06 HaronK