Enum Value

Source
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>

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, NumericTypes>

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<NumericTypes::Int, NumericTypes>

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<NumericTypes::Float, NumericTypes>

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<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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

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

Source

pub fn str_from(&self) -> String

Returns a string for the str::from built-in function.

Source

pub fn from_float(float: NumericTypes::Float) -> Self

Create a new Value from its corresponding raw float type.

Source

pub fn from_int(int: NumericTypes::Int) -> Self

Create a new Value from its corresponding raw int type.

Trait Implementations§

Source§

impl<NumericTypes: Clone + EvalexprNumericTypes> Clone for Value<NumericTypes>
where NumericTypes::Float: Clone, NumericTypes::Int: Clone,

Source§

fn clone(&self) -> Value<NumericTypes>

Returns a duplicate 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<NumericTypes: Debug + EvalexprNumericTypes> Debug for Value<NumericTypes>
where NumericTypes::Float: Debug, NumericTypes::Int: Debug,

Source§

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

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

impl<NumericTypes: EvalexprNumericTypes> Display for Value<NumericTypes>

Source§

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

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

impl<NumericTypes: EvalexprNumericTypes> From<&&mut Value<NumericTypes>> for ValueType

Source§

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

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<&Value<NumericTypes>> for ValueType

Source§

fn from(value: &Value<NumericTypes>) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<&mut Value<NumericTypes>> for ValueType

Source§

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

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<&str> for Value<NumericTypes>

Source§

fn from(string: &str) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<()> for Value<NumericTypes>

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<String> for Value<NumericTypes>

Source§

fn from(string: String) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<Value<NumericTypes>> for EvalexprResultValue<NumericTypes>

Source§

fn from(value: Value<NumericTypes>) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<Vec<Value<NumericTypes>>> for Value<NumericTypes>

Source§

fn from(tuple: TupleType<NumericTypes>) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: EvalexprNumericTypes> From<bool> for Value<NumericTypes>

Source§

fn from(boolean: bool) -> Self

Converts to this type from the input type.
Source§

impl<NumericTypes: PartialEq + EvalexprNumericTypes> PartialEq for Value<NumericTypes>
where NumericTypes::Float: PartialEq, NumericTypes::Int: PartialEq,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<NumericTypes: EvalexprNumericTypes> TryFrom<Value<NumericTypes>> for ()

Source§

type Error = EvalexprError<NumericTypes>

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

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

Performs the conversion.
Source§

impl<NumericTypes: EvalexprNumericTypes> TryFrom<Value<NumericTypes>> for String

Source§

type Error = EvalexprError<NumericTypes>

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

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

Performs the conversion.
Source§

impl<NumericTypes: EvalexprNumericTypes> TryFrom<Value<NumericTypes>> for TupleType<NumericTypes>

Source§

type Error = EvalexprError<NumericTypes>

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

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

Performs the conversion.
Source§

impl<NumericTypes: EvalexprNumericTypes> TryFrom<Value<NumericTypes>> for bool

Source§

type Error = EvalexprError<NumericTypes>

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

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

Performs the conversion.
Source§

impl<NumericTypes: EvalexprNumericTypes> StructuralPartialEq for Value<NumericTypes>

Auto Trait Implementations§

§

impl<NumericTypes> Freeze for Value<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Float: Freeze, <NumericTypes as EvalexprNumericTypes>::Int: Freeze,

§

impl<NumericTypes> RefUnwindSafe for Value<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Float: RefUnwindSafe, <NumericTypes as EvalexprNumericTypes>::Int: RefUnwindSafe,

§

impl<NumericTypes> Send for Value<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Float: Send, <NumericTypes as EvalexprNumericTypes>::Int: Send,

§

impl<NumericTypes> Sync for Value<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Float: Sync, <NumericTypes as EvalexprNumericTypes>::Int: Sync,

§

impl<NumericTypes> Unpin for Value<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Float: Unpin, <NumericTypes as EvalexprNumericTypes>::Int: Unpin,

§

impl<NumericTypes> UnwindSafe for Value<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Float: UnwindSafe, <NumericTypes as EvalexprNumericTypes>::Int: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.