Macro rglua::reg[][src]

macro_rules! reg {
    ($($name : expr => $func : expr), *) => { ... };
}
Expand description

Creates an array of LuaRegs for you to be used with luaL_register

Examples

Basic usage

use rglua::prelude::*;
extern "C" fn max(l: LuaState) -> i32 { 0 }
extern "C" fn min(l: LuaState) -> i32 { 0 }
let my_library = reg! [
    "max" => max,
    "min" => min
];
assert_eq!(my_library.len(), 3); // 2 functions + 1 internal null terminator
unsafe { assert_eq!(my_library[0].name, cstr!("max")) }; // Internally this is turned into &[ LuaReg { name: cstr!("max"), func: max }, ... ];

Returns a &crate::types::LuaReg