Enum endbasic_core::ast::Value

source ·
pub enum Value {
    Boolean(bool),
    Double(f64),
    Integer(i32),
    Text(String),
}
Expand description

Represents an evaluated value.

Variants§

§

Boolean(bool)

A boolean value.

§

Double(f64)

A double-precision floating point value.

§

Integer(i32)

An integer value.

§

Text(String)

A string value.

Implementations§

Returns the type of the value as a VarType.

Consumes the value and converts it to a string value. This is slightly different from the Display implementation because strings aren’t double-quoted.

The output of this function is used anything a value is converted to a string, say as the output of PRINT.

This is not named to_string to prevent confusion with the behavior of a traditional method named like that, and to avoid conflicts with the Display implementation.

Parses a string s and constructs a Value that matches a given VarType.

Reinterprets this value as an i32 and fails if the conversion is not possible.

Reinterprets this value as an f64 and fails if the conversion is not possible.

Given a target variable type, tries to convert the value to that type if they are compatible or otherwise returns self.

Can return an error when the conversion is feasible but it is not possible, such as trying to cast a NaN to an integer.

Performs a logical or bitwise “and” operation.

Performs a logical or bitwise “or” operation.

Performs a logical or bitwise “xor” operation.

Performs a logical or bitwise “not” operation.

Performs a left shift.

Performs a right shift.

Performs an equality check.

Performs an inequality check.

Performs a less-than check.

Performs a less-than or equal-to check.

Performs a greater-than check.

Performs a greater-than or equal to check.

Performs an arithmetic addition.

Performs an arithmetic subtraction.

Performs a multiplication.

Performs an arithmetic division.

Performs a modulo operation.

Performs a power operation.

Performs an arithmetic negation.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.