update rust crates to 2024 edition

This commit is contained in:
2025-03-01 23:43:31 +01:00
parent f033739bba
commit 28001a2040
10 changed files with 50 additions and 30 deletions

View File

@@ -1,18 +1,20 @@
use std::ffi::{c_char, CStr};
use mlua::Lua;
#![allow(clippy::missing_safety_doc)]
#[no_mangle]
pub extern "C" fn lua_new() -> *mut Lua {
use mlua::Lua;
use std::ffi::{CStr, c_char};
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lua_new() -> *mut Lua {
let lua = Lua::new();
Box::into_raw(Box::new(lua))
}
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lua_execute(lua: *mut Lua, to_execute: *const c_char) {
let lua: &mut Lua = &mut *lua;
let to_execute = CStr::from_ptr(to_execute);
let lua: &mut Lua = unsafe { &mut *lua };
let to_execute = unsafe { CStr::from_ptr(to_execute) };
if let Err(err) = lua.load(&to_execute.to_string_lossy().to_string()).exec() {
if let Err(err) = lua.load(to_execute.to_string_lossy().to_string()).exec() {
eprintln!("{}", err)
}
}