The Other variant of the mlua::Value enumeration contains a private type, which means it is impossible to match on it like:
mlua::Value::Nil => serde_json::Value::Null,
mlua::Value::Boolean(b) => serde_json::Value::Bool(b),
mlua::Value::Integer(i) => serde_json::Value::Number(i.into()),
mlua::Value::Number(n) => {...}
mlua::Value::String(s) => {...}
mlua::Value::Table(t) => {...}
mlua::Value::Function(_)
| mlua::Value::LightUserData(_)
| mlua::Value::Thread(_)
| mlua::Value::UserData(_)
| mlua::Value::Other(_)
| mlua::Value::Error(_) => Err(anyhow::anyhow!(
"Error converting Lua type to unsupported JSON type"
))
which yields:
rustc: error: type `mlua::types::value_ref::ValueRef` is private
--> lib/rs/lib-workflow/src/lua/mod.rs:310:30
|
310 | | mlua::Value::Other(_)
| ^ private type
We can just match on _, but we generally prefer exhaustive matches wherever possible, so that when new variants are introduced, we're sure to check to see whether we need to handle them.
The
Othervariant of themlua::Valueenumeration contains a private type, which means it is impossible to match on it like:which yields:
We can just match on
_, but we generally prefer exhaustive matches wherever possible, so that when new variants are introduced, we're sure to check to see whether we need to handle them.