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: ErrorKindWhat kind of error (1 byte + padding)
expr: ArenaIndexThe expression that caused the error
message: &'static strHuman-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
impl EvalError
pub const fn new(kind: ErrorKind) -> Self
pub const fn with_expr(self, expr: ArenaIndex) -> Self
pub const fn with_message(self, msg: &'static str) -> Self
pub const fn with_types(self, expected: &'static str, got: &'static str) -> Self
pub const fn with_args(self, expected: usize, got: usize) -> Self
Sourcepub fn from_parse_error(e: ParseError, expr: ArenaIndex) -> Self
pub fn from_parse_error(e: ParseError, expr: ArenaIndex) -> Self
Create an EvalError from a ParseError with expression context
Trait Implementations§
Source§impl From<ArenaError> for EvalError
impl From<ArenaError> for EvalError
Source§fn from(e: ArenaError) -> Self
fn from(e: ArenaError) -> Self
Converts to this type from the input type.
Source§impl From<ParseError> for EvalError
impl From<ParseError> for EvalError
Source§fn from(e: ParseError) -> Self
fn from(e: ParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for EvalError
impl RefUnwindSafe for EvalError
impl Send for EvalError
impl Sync for EvalError
impl Unpin for EvalError
impl UnwindSafe for EvalError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more