()
| 4 | |
| 5 | |
| 6 | fn main() -> LuaResult<()> { |
| 7 | println!("Hello, world!"); |
| 8 | |
| 9 | let lua = unsafe { Lua::unsafe_new() }; |
| 10 | |
| 11 | let globals = lua.globals(); |
| 12 | let package_table: LuaTable = globals.get("package")?; |
| 13 | let cpath: String = package_table.get("cpath")?; |
| 14 | |
| 15 | |
| 16 | let script = fs::read_to_string("mylua.lua") |
| 17 | .expect("无法读取 mylua.lua,请确保文件在当前目录"); |
| 18 | |
| 19 | match lua.load(&script).exec() { |
| 20 | Ok(_) => println!("Lua 脚本执行完成"), |
| 21 | Err(e) => eprintln!("Lua 执行出错: {}", e), |
| 22 | } |
| 23 | |
| 24 | Ok(()) |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected