I'm confused if (and through which syntax) it's possible to assign trait bounds to arguments of a Fn
closure inside a type alias.
I'm trying to define the following
pub type LuaFn = Box<
dyn 'static
+ Send
// Doesn't work.
+ for<'lua> Fn<Args: ToLuaMulti<'lua>>(&'lua Lua, Args) -> mlua::Result<()>,
>;
where Lua
is a struct and ToLuaMulti
is a trait. This also doesn't work
pub type LuaFn = Box<
dyn 'static
+ Send
+ for<'lua> Fn(&'lua Lua, impl ToLuaMulti<'lua>) -> mlua::Result<()>,
>;
This works but it's not what I'm trying to do: LuaFn
shouldn't be generic and Args
should implement ToLuaMulti
:
pub type LuaFn<Args> = Box<
dyn 'static + Send + for<'lua> Fn(&'lua Lua, Args) -> mlua::Result<()>,
>;