Enum darklua_core::process::LuaValue [−][src]
Expand description
Represents an evaluated Expression result.
Variants
Number(f64)
Tuple Fields of Number
0: f64
String(String)
Tuple Fields of String
0: String
Implementations
As defined in Lua, all values are considered true, except for false and nil. An option is returned as the LuaValue may be unknown, so it would return none.
// the values considered false
assert!(!LuaValue::False.is_truthy().unwrap());
assert!(!LuaValue::Nil.is_truthy().unwrap());
// all the others are true
assert!(LuaValue::True.is_truthy().unwrap());
assert!(LuaValue::Table.is_truthy().unwrap());
assert!(LuaValue::Number(0.0).is_truthy().unwrap());
assert!(LuaValue::String("hello".to_owned()).is_truthy().unwrap());
// unknown case
assert!(LuaValue::Unknown.is_truthy().is_none());
If the value is unknown, this will also return unknown value. In the other case, if the
value is considered truthy (see is_truthy
function), it will call the given function to
get the mapped value.
pub fn map_if_truthy_else<F, G>(self, map: F, default: G) -> Self where
F: Fn(Self) -> Self,
G: Fn() -> Self,
pub fn map_if_truthy_else<F, G>(self, map: F, default: G) -> Self where
F: Fn(Self) -> Self,
G: Fn() -> Self,
Like the map_if_truthy
method, except that instead of returning the same value when the
it is falsy, it calls the default callback to obtain another value.
Attempt to convert the Lua value into an expression node.
Attempt to convert the Lua value into a number value. This will convert strings when possible and return the same value otherwise.
Attempt to convert the Lua value into a string value. This will convert numbers when possible and return the same value otherwise.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for LuaValue
impl UnwindSafe for LuaValue
Blanket Implementations
Mutably borrows from an owned value. Read more