Struct tlua::LuaCodeFromReader [−][src]
pub struct LuaCodeFromReader<R>(pub R);Expand description
Wrapper around a Read object. When pushed, the content will be parsed as Lua code and turned
into a function.
Since pushing this value can fail in case of a reading error or a parsing error, you must use
the checked_set method instead of set.
Example: returning a Lua function from a Rust function
use std::io::Cursor;
let mut lua = tlua::Lua::new();
lua.set("call_rust", tlua::function0(|| -> tlua::LuaCodeFromReader<Cursor<String>> {
let lua_code = "return 18;";
return tlua::LuaCodeFromReader(Cursor::new(lua_code.to_owned()));
}));
let r: i32 = lua.eval("local lua_func = call_rust(); return lua_func();").unwrap();
assert_eq!(r, 18);Tuple Fields
0: RTrait Implementations
Push the value into lua by value
