low-luajit 0.4.0

Low level but safe bindings to the LuaJIT C API with no dependencies and no-std support to create Lua modules using Rust.
Documentation
use low_luajit::{AmountReturned, LuaState, LuaType};

extern "C-unwind" fn join(mut lua: LuaState) -> AmountReturned {
	// Check that the first argument is a function.
	lua.check_type(1, LuaType::Function);

	let top = lua.get_top();

	// Move the function to the top of the stack and call it to have all its returned values pushed onto the stack.
	lua.push_value(1);
	lua.remove(1);
	lua.call(0, LuaState::MULTI_RETURN);

	// The values returned by the function should come *before* join's arguments, so let's move them back to the bottom of the stack.
	let final_top = lua.get_top();
	for _ in top..=final_top {
		lua.insert(1);
	}

	// Return all the values in the stack.
	lua.return_any(final_top)
}

#[unsafe(no_mangle)]
extern "C-unwind" fn luaopen_join_varargs(lua: LuaState) -> AmountReturned {
	lua.return_cfunction(join)
}