pub enum Value {
String(String),
Float(FloatType),
Int(IntType),
Boolean(bool),
Tuple(TupleType),
Empty,
}
Expand description
The value type used by the parser. Values can be of different subtypes that are the variants of this enum.
Variants§
String(String)
A string value.
Float(FloatType)
A float value.
Int(IntType)
An integer value.
Boolean(bool)
A boolean value.
Tuple(TupleType)
A tuple value.
Empty
An empty value.
Implementations§
source§impl Value
impl Value
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if self
is a Value::Boolean
.
sourcepub fn as_string(&self) -> EvalexprResult<String>
pub fn as_string(&self) -> EvalexprResult<String>
Clones the value stored in self
as String
, or returns Err
if self
is not a Value::String
.
sourcepub fn as_int(&self) -> EvalexprResult<IntType>
pub fn as_int(&self) -> EvalexprResult<IntType>
Clones the value stored in self
as IntType
, or returns Err
if self
is not a Value::Int
.
sourcepub fn as_float(&self) -> EvalexprResult<FloatType>
pub fn as_float(&self) -> EvalexprResult<FloatType>
Clones the value stored in self
as FloatType
, or returns Err
if self
is not a Value::Float
.
sourcepub fn as_number(&self) -> EvalexprResult<FloatType>
pub fn as_number(&self) -> EvalexprResult<FloatType>
Clones the value stored in self
as FloatType
, or returns Err
if self
is not a Value::Float
or Value::Int
.
Note that this method silently converts IntType
to FloatType
, if self
is a Value::Int
.
sourcepub fn as_boolean(&self) -> EvalexprResult<bool>
pub fn as_boolean(&self) -> EvalexprResult<bool>
Clones the value stored in self
as bool
, or returns Err
if self
is not a Value::Boolean
.
sourcepub fn as_tuple(&self) -> EvalexprResult<TupleType>
pub fn as_tuple(&self) -> EvalexprResult<TupleType>
Clones the value stored in self
as TupleType
, or returns Err
if self
is not a Value::Tuple
.
sourcepub fn as_fixed_len_tuple(&self, len: usize) -> EvalexprResult<TupleType>
pub fn as_fixed_len_tuple(&self, len: usize) -> EvalexprResult<TupleType>
Clones the value stored in self
as TupleType
or returns Err
if self
is not a Value::Tuple
of the required length.
sourcepub fn as_empty(&self) -> EvalexprResult<()>
pub fn as_empty(&self) -> EvalexprResult<()>
Returns ()
, or returnsErr
if self
is not a Value::Tuple
.