[−][src]Enum darklua_core::process::LuaValue
Represents an evaluated Expression result.
Variants
Number(f64)
String(String)
Implementations
impl LuaValue
[src]
pub fn is_truthy(&self) -> Option<bool>
[src]
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());
pub fn map_if_truthy<F>(self, map: F) -> Self where
F: Fn(Self) -> Self,
[src]
F: Fn(Self) -> Self,
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,
[src]
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.
pub fn to_expression(self) -> Option<Expression>
[src]
Attempt to convert the Lua value into an expression node.
pub fn number_coercion(self) -> Self
[src]
Attempt to convert the Lua value into a number value. This will convert strings when possible and return the same value otherwise.
Trait Implementations
impl Clone for LuaValue
[src]
impl Debug for LuaValue
[src]
impl Default for LuaValue
[src]
impl<'_> From<&'_ str> for LuaValue
[src]
impl From<String> for LuaValue
[src]
impl From<bool> for LuaValue
[src]
impl From<f64> for LuaValue
[src]
impl PartialEq<LuaValue> for LuaValue
[src]
impl StructuralPartialEq for LuaValue
[src]
Auto Trait Implementations
impl RefUnwindSafe for LuaValue
impl Send for LuaValue
impl Sync for LuaValue
impl Unpin for LuaValue
impl UnwindSafe for LuaValue
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,