pub enum Value<NumericTypes: EvalexprNumericTypes = DefaultNumericTypes> {
String(String),
Float(NumericTypes::Float),
Int(NumericTypes::Int),
Boolean(bool),
Tuple(TupleType<NumericTypes>),
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(NumericTypes::Float)
A float value.
Int(NumericTypes::Int)
An integer value.
Boolean(bool)
A boolean value.
Tuple(TupleType<NumericTypes>)
A tuple value.
Empty
An empty value.
Implementations§
Source§impl<NumericTypes: EvalexprNumericTypes> Value<NumericTypes>
impl<NumericTypes: EvalexprNumericTypes> Value<NumericTypes>
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, NumericTypes>
pub fn as_string(&self) -> EvalexprResult<String, NumericTypes>
Clones the value stored in self as String, or returns Err if self is not a Value::String.
Sourcepub fn as_int(&self) -> EvalexprResult<NumericTypes::Int, NumericTypes>
pub fn as_int(&self) -> EvalexprResult<NumericTypes::Int, NumericTypes>
Clones the value stored in self as IntType, or returns Err if self is not a Value::Int.
Sourcepub fn as_float(&self) -> EvalexprResult<NumericTypes::Float, NumericTypes>
pub fn as_float(&self) -> EvalexprResult<NumericTypes::Float, NumericTypes>
Clones the value stored in self as FloatType, or returns Err if self is not a Value::Float.
Sourcepub fn as_number(&self) -> EvalexprResult<NumericTypes::Float, NumericTypes>
pub fn as_number(&self) -> EvalexprResult<NumericTypes::Float, NumericTypes>
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, NumericTypes>
pub fn as_boolean(&self) -> EvalexprResult<bool, NumericTypes>
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<NumericTypes>, NumericTypes>
pub fn as_tuple(&self) -> EvalexprResult<TupleType<NumericTypes>, NumericTypes>
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<NumericTypes>, NumericTypes>
pub fn as_fixed_len_tuple( &self, len: usize, ) -> EvalexprResult<TupleType<NumericTypes>, NumericTypes>
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_ranged_len_tuple(
&self,
range: RangeInclusive<usize>,
) -> EvalexprResult<TupleType<NumericTypes>, NumericTypes>
pub fn as_ranged_len_tuple( &self, range: RangeInclusive<usize>, ) -> EvalexprResult<TupleType<NumericTypes>, NumericTypes>
Clones the value stored in self as TupleType or returns Err if self is not a Value::Tuple with length in the required range.
Sourcepub fn as_empty(&self) -> EvalexprResult<(), NumericTypes>
pub fn as_empty(&self) -> EvalexprResult<(), NumericTypes>
Returns (), or returnsErr if self is not a Value::Tuple.
Sourcepub fn from_float(float: NumericTypes::Float) -> Self
pub fn from_float(float: NumericTypes::Float) -> Self
Create a new Value from its corresponding raw float type.