It’s hard to tell what it is you’re trying to do here, but maybe Option isn’t the right type? To me it feels like you’d want to return a type like Vec
or an iterator.
I would recommend looking at some of the iterator functions to do this. You could look at filter_map
, collect
, and fold
/try_fold
and see if any of those help you here.
You can embed Lua pretty easily using a few different libraries. One I liked in particular was
mlua
. Lua is tiny, usually sufficiently fast, and easy to learn.Otherwise, there are some others like Rhai, but there may be fewer resources available for users if you go with a less popular language.