pub enum Value {
Boolean(bool),
String(String),
Number(f64),
Array(Vec<Value>),
}Expand description
A Wrapper for the four different possible variable types.
Variants§
Implementations§
Source§impl Value
impl Value
Sourcepub fn div_int(self, rhs: Self) -> Result<Self>
pub fn div_int(self, rhs: Self) -> Result<Self>
Integer division between two operands. Returns the whole number quotient, discarding any fractional part.
§Examples
use slac::Value;
let a = Value::Number(10.0);
let b = Value::Number(3.0);
assert_eq!(Ok(Value::Number(3.0)), a.div_int(b));§Errors
Returns Error::InvalidBinaryOperator if any side of the operator is not a Number.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of a String or Array Value.
Boolean and Number have a length of 0.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the value is equal to the result of Value::empty().
Sourcepub fn empty(&self) -> Self
pub fn empty(&self) -> Self
Returns an new empty Value of the same type as the callee.
Value::Boolean->falseValue::String->''Value::Number->0Value::Array->[]
Sourcepub fn as_bool(&self) -> bool
pub fn as_bool(&self) -> bool
Returns the boolean representation of the Value.
Returns Booleans as is. Other Value kinds are based on
if the contained value is not Value::is_empty().
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Value
Available on crate feature
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<NaiveDateTime> for Value
impl From<NaiveDateTime> for Value
Source§fn from(val: NaiveDateTime) -> Self
fn from(val: NaiveDateTime) -> Self
Converts to this type from the input type.
Source§impl Ord for Value
impl Ord for Value
Source§impl PartialOrd for Value
impl PartialOrd for Value
Source§impl TryFrom<&Value> for NaiveDateTime
impl TryFrom<&Value> for NaiveDateTime
impl Eq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more