Go back to matching on bool since it was more obvious

This commit is contained in:
Filip Tibell 2023-01-20 21:09:08 -05:00
parent 3c3a798fbb
commit af3d022f5d
No known key found for this signature in database
2 changed files with 7 additions and 6 deletions

View file

@ -132,12 +132,15 @@ async fn process_spawn(lua: &Lua, (program, args): (String, Option<Vec<String>>)
.wait_with_output()
.await
.map_err(mlua::Error::external)?;
// NOTE: Exit code defaults to 1 if it did not exist and if there
// is any stderr, will otherwise default to 0 if it did not exist
// NOTE: If an exit code was not given by the child process,
// we default to 1 if it yielded any error output, otherwise 0
let code = output
.status
.code()
.unwrap_or_else(|| i32::from(!output.stderr.is_empty()));
.unwrap_or(match output.stderr.is_empty() {
true => 0,
false => 1,
});
// Construct and return a readonly lua table with results
let table = lua.create_table()?;
table.raw_set("ok", code == 0)?;

View file

@ -1,7 +1,5 @@
#![deny(clippy::all, clippy::cargo, clippy::pedantic)]
// mlua does not implement userdata for &str
// so in some cases we have to use String
#![allow(clippy::needless_pass_by_value)]
#![allow(clippy::needless_pass_by_value, clippy::match_bool)]
use clap::Parser;
use mlua::Result;