Enum Error
pub enum Error {
ShapeMismatch {
expected: Shape,
got: Shape,
},
RankMismatch {
expected: usize,
got: usize,
},
DTypeMismatch {
expected: DType,
got: DType,
},
DimOutOfRange {
dim: usize,
rank: usize,
},
NarrowOutOfBounds {
dim: usize,
start: usize,
len: usize,
dim_size: usize,
},
NotAScalar {
shape: Shape,
},
ElementCountMismatch {
shape: Shape,
expected: usize,
got: usize,
},
MatmulShapeMismatch {
m: usize,
k1: usize,
k2: usize,
n: usize,
},
ReshapeElementMismatch {
src: usize,
dst: usize,
dst_shape: Shape,
},
Msg(String),
}Expand description
Re-export core types. All errors that can occur within Shrew.
This enum captures every failure mode: shape mismatches, dtype mismatches, device mismatches, out-of-bounds indexing, and backend-specific errors. Using a single error type across the library simplifies error propagation.
Variants§
ShapeMismatch
Shape mismatch between two tensors (e.g., trying to add [2,3] + [4,5]).
RankMismatch
Operation requires a specific rank (number of dimensions).
DTypeMismatch
DType mismatch between tensors in a binary operation.
DimOutOfRange
Dimension index out of range for the tensor’s rank.
NarrowOutOfBounds
Narrow/slice operation out of bounds.
NotAScalar
Tried to access a scalar from a non-scalar tensor.
ElementCountMismatch
Element count mismatch when creating from a vec.
MatmulShapeMismatch
Matrix multiplication dimension mismatch.
ReshapeElementMismatch
Cannot reshape because element counts differ.
Msg(String)
Generic message for cases not covered above.
Implementations§
Trait Implementations§
§impl Error for Error
impl Error for Error
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
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
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> 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