Enum evalexpr::Value

source ·
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

source

pub fn is_string(&self) -> bool

Returns true if self is a Value::String.

source

pub fn is_int(&self) -> bool

Returns true if self is a Value::Int.

source

pub fn is_float(&self) -> bool

Returns true if self is a Value::Float.

source

pub fn is_number(&self) -> bool

Returns true if self is a Value::Int or Value::Float.

source

pub fn is_boolean(&self) -> bool

Returns true if self is a Value::Boolean.

source

pub fn is_tuple(&self) -> bool

Returns true if self is a Value::Tuple.

source

pub fn is_empty(&self) -> bool

Returns true if self is a Value::Empty.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn as_empty(&self) -> EvalexprResult<()>

Returns (), or returnsErr if self is not a Value::Tuple.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl From<&&mut Value> for ValueType

source§

fn from(value: &&mut Value) -> Self

Converts to this type from the input type.
source§

impl From<&Value> for ValueType

source§

fn from(value: &Value) -> Self

Converts to this type from the input type.
source§

impl From<&mut Value> for ValueType

source§

fn from(value: &mut Value) -> Self

Converts to this type from the input type.
source§

impl From<&str> for Value

source§

fn from(string: &str) -> Self

Converts to this type from the input type.
source§

impl From<()> for Value

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(string: String) -> Self

Converts to this type from the input type.
source§

impl From<Value> for EvalexprResult<Value>

source§

fn from(value: Value) -> Self

Converts to this type from the input type.
source§

impl From<Vec<Value, Global>> for Value

source§

fn from(tuple: TupleType) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(boolean: bool) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(float: FloatType) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(int: IntType) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Value> for Value

source§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Value> for ()

§

type Error = EvalexprError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for FloatType

§

type Error = EvalexprError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for IntType

§

type Error = EvalexprError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for String

§

type Error = EvalexprError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for TupleType

§

type Error = EvalexprError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for bool

§

type Error = EvalexprError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.