Skip to main content

InferredType

Enum InferredType 

Source
pub enum InferredType {
Show 13 variants Integer, Float, String, Boolean, Null, Array(Box<InferredType>), Object, Date, DateTime, Duration, Unknown, Numeric, Error(String),
}
Expand description

Inferred type of an ELO expression

Variants§

§

Integer

Integer type

§

Float

Float type

§

String

String type

§

Boolean

Boolean type

§

Null

Null/None type

§

Array(Box<InferredType>)

Array with element type

§

Object

Object with field types (simplified - just track it’s an object)

§

Date

Date type

§

DateTime

DateTime type

§

Duration

Duration type

§

Unknown

Unknown type (when inference fails or type can’t be determined)

§

Numeric

Any numeric type (integer or float)

§

Error(String)

Type error - incompatible types

Implementations§

Source§

impl InferredType

Source

pub fn is_numeric(&self) -> bool

Check if this is a numeric type

Source

pub fn is_scalar(&self) -> bool

Check if this is a scalar type

Source

pub fn is_error(&self) -> bool

Check if this is an error type

Source

pub fn common_type(a: &InferredType, b: &InferredType) -> InferredType

Get a common type that’s compatible with both types

Trait Implementations§

Source§

impl Clone for InferredType

Source§

fn clone(&self) -> InferredType

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 Debug for InferredType

Source§

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

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

impl Display for InferredType

Source§

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

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

impl PartialEq for InferredType

Source§

fn eq(&self, other: &InferredType) -> 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 Visitor<InferredType> for TypeInferenceVisitor

Source§

fn visit_expr(&mut self, expr: &Expr) -> InferredType

Visit a generic expression, dispatching to specific methods
Source§

fn visit_literal(&mut self, lit: &Literal) -> InferredType

Visit a literal value (number or boolean)
Source§

fn visit_null(&mut self) -> InferredType

Visit a null literal
Source§

fn visit_identifier(&mut self, _name: &str) -> InferredType

Visit an identifier (variable reference)
Source§

fn visit_field_access(&mut self, _receiver: &Expr, _field: &str) -> InferredType

Visit a field access expression
Source§

fn visit_binary_op( &mut self, op: BinaryOperator, left: &Expr, right: &Expr, ) -> InferredType

Visit a binary operation
Source§

fn visit_unary_op(&mut self, op: UnaryOperator, operand: &Expr) -> InferredType

Visit a unary operation
Source§

fn visit_function_call(&mut self, name: &str, args: &[Expr]) -> InferredType

Visit a function call
Source§

fn visit_lambda(&mut self, _param: &str, _body: &Expr) -> InferredType

Visit a lambda expression
Source§

fn visit_let(&mut self, _name: &str, _value: &Expr, body: &Expr) -> InferredType

Visit a let binding
Source§

fn visit_if( &mut self, _condition: &Expr, then_branch: &Expr, else_branch: &Expr, ) -> InferredType

Visit an if conditional
Source§

fn visit_array(&mut self, elements: &[Expr]) -> InferredType

Visit an array literal
Source§

fn visit_object(&mut self, _fields: &[(String, Expr)]) -> InferredType

Visit an object literal
Source§

fn visit_pipe(&mut self, value: &Expr, functions: &[Expr]) -> InferredType

Visit a pipe operator
Source§

fn visit_alternative( &mut self, primary: &Expr, alternative: &Expr, ) -> InferredType

Visit an alternative operator (?|)
Source§

fn visit_guard(&mut self, _condition: &Expr, body: &Expr) -> InferredType

Visit a guard expression
Source§

fn visit_date(&mut self, _date: &str) -> InferredType

Visit a date literal
Source§

fn visit_datetime(&mut self, _datetime: &str) -> InferredType

Visit a datetime literal
Source§

fn visit_duration(&mut self, _duration: &str) -> InferredType

Visit a duration literal
Source§

fn visit_temporal_keyword(&mut self, _keyword: TemporalKeyword) -> InferredType

Visit a temporal keyword
Source§

fn visit_string(&mut self, _value: &str) -> InferredType

Visit a string literal
Source§

impl Eq for InferredType

Source§

impl StructuralPartialEq for InferredType

Auto Trait Implementations§

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.