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
sourceimpl 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
.
Trait Implementations
sourceimpl From<Value> for EvalexprResult<Value>
impl From<Value> for EvalexprResult<Value>
impl StructuralPartialEq for Value
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more