Skip to main content

EvalError

Struct EvalError 

Source
pub struct EvalError {
    pub kind: ErrorKind,
    pub expr: ArenaIndex,
    pub message: &'static str,
    pub expected: Option<&'static str>,
    pub got: Option<&'static str>,
    pub arg_info: Option<ArgCountInfo>,
    pub parse_error: Option<ParseError>,
}
Expand description

Evaluation error with context - optimized for minimal size.

§Size Optimization

This struct is kept small (~88 bytes on 64-bit) to minimize stack usage:

  • No inline backtrace array (saves ~256 bytes)
  • Static string messages instead of inline buffers (saves ~56 bytes)
  • Compact arg count representation (saves ~24 bytes)

Fields§

§kind: ErrorKind

What kind of error (1 byte + padding)

§expr: ArenaIndex

The expression that caused the error

§message: &'static str

Human-readable message context (static string, 16 bytes)

§expected: Option<&'static str>

Expected and got types for type errors (2 × 16 bytes)

§got: Option<&'static str>§arg_info: Option<ArgCountInfo>

Argument count info for WrongArgCount errors (4 bytes)

§parse_error: Option<ParseError>

Original parse error (if applicable)

Implementations§

Source§

impl EvalError

Source

pub const fn new(kind: ErrorKind) -> Self

Source

pub const fn with_expr(self, expr: ArenaIndex) -> Self

Source

pub const fn with_message(self, msg: &'static str) -> Self

Source

pub const fn with_types(self, expected: &'static str, got: &'static str) -> Self

Source

pub const fn with_args(self, expected: usize, got: usize) -> Self

Source

pub fn from_parse_error(e: ParseError, expr: ArenaIndex) -> Self

Create an EvalError from a ParseError with expression context

Trait Implementations§

Source§

impl Debug for EvalError

Source§

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

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

impl From<ArenaError> for EvalError

Source§

fn from(e: ArenaError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for EvalError

Source§

fn from(e: ParseError) -> Self

Converts to this type from the input type.

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