pub enum RuntimeError {
IndexOutOfBounds {
index: usize,
length: usize,
},
ShapeMismatch {
expected: usize,
got: usize,
},
DimensionMismatch {
expected: usize,
got: usize,
},
InvalidOperation(String),
}Expand description
Errors produced by the CJC runtime.
All runtime operations that can fail return Result<T, RuntimeError>.
This enum covers the four main failure modes: index violations, shape
incompatibilities, dimension mismatches, and general invalid operations.
RuntimeError implements std::error::Error and [Display] for
integration with Rust’s standard error handling.
Variants§
IndexOutOfBounds
An index exceeded the valid range for a buffer or tensor dimension.
index is the out-of-bounds index that was provided, and length
is the size of the dimension or buffer that was indexed into.
ShapeMismatch
The total number of elements did not match what the shape requires.
Raised by [Tensor::from_vec] when data.len() != product(shape),
and by [Tensor::reshape] when the new shape’s element count differs.
Fields
DimensionMismatch
The number of dimensions (rank) did not match what was expected.
Raised by operations like [Tensor::matmul] (requires 2-D) or
[Tensor::get] (index length must match ndim).
Fields
InvalidOperation(String)
A catch-all for operations that are invalid for the given arguments.
The contained String provides a human-readable description of
what went wrong (e.g., “matmul requires 2-D tensors”).
Trait Implementations§
Source§impl Clone for RuntimeError
impl Clone for RuntimeError
Source§fn clone(&self) -> RuntimeError
fn clone(&self) -> RuntimeError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RuntimeError
impl Debug for RuntimeError
Source§impl Display for RuntimeError
impl Display for RuntimeError
Source§impl Error for RuntimeError
impl Error for RuntimeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for RuntimeError
impl RefUnwindSafe for RuntimeError
impl Send for RuntimeError
impl Sync for RuntimeError
impl Unpin for RuntimeError
impl UnsafeUnpin for RuntimeError
impl UnwindSafe for RuntimeError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more