Add send+anyhow support for mlua

Ref: https://github.com/khvzak/mlua/issues/48
pull/164/head
Arijit Basu 3 years ago committed by Arijit Basu
parent f744553a0a
commit 6cc863e6d4

@ -29,7 +29,7 @@ lazy_static = "1.4.0"
indexmap = { version = "1.6.2", features = ["serde"] }
natord = "1.0.9"
humansize = "1.1.0"
mlua = { version = "0.5.4", features = ["luajit", "vendored", "serialize"] }
mlua = { version = "0.5.4", features = ["luajit", "vendored", "serialize", "send"] }
[dev-dependencies]
criterion = "0.3"

@ -1492,30 +1492,22 @@ impl App {
// TODO: https://github.com/khvzak/mlua/issues/48
if let Err(e) = lua.to_value(&luadata).and_then(|v| globals.set("xplr", v)) {
bail!(e.to_string())
};
lua.to_value(&luadata)
.and_then(|v| globals.set("xplr", v))?;
if let Err(e) = lua
.load(&lua_script)
lua.load(&lua_script)
.set_name("init")
.and_then(|l| l.exec())
{
bail!(e.to_string())
}
.and_then(|l| l.exec())?;
let version: String = match globals.get("version").and_then(|v| lua.from_value(v)) {
Ok(v) => v,
Err(_) => bail!(format!(
"'version' must globally be defined in {}",
"'version' must be defined globally in {}",
&lua_script_file.to_string_lossy().to_string()
)),
};
let luadata: LuaData = match globals.get("xplr").and_then(|v| lua.from_value(v)) {
Ok(d) => d,
Err(e) => bail!(e.to_string()),
};
let luadata: LuaData = globals.get("xplr").and_then(|v| lua.from_value(v))?;
luadata.config.with_version(version)
} else {

Loading…
Cancel
Save