Skip to content

Commit 3a59caa

Browse files
committed
FEAT: Encode expected/actual info in ShapeError
Add a (limited) way to add specific information to a ShapeError Admittedly wonky, but space efficient. Result<(), ShapeError> used to be 1 byte, and with this change it expands to 16 bytes (2 usize on 64-bit). The remaining 15 bytes are used for optimistically packing as much of extra info into the error message as possible. For example we can store expected/actual index for errors (for example index out of bounds or axis out of bounds, these are not so commonly handled with ShapeError). With this change it is supported: - Expected/actual index with 7 bytes per index - Expected/actual shape with 7 bytes per shape supports storing shapes with one or two bytes (< 256²) per dimension, with limited ndim.
1 parent da365be commit 3a59caa

File tree

4 files changed

+530
-10
lines changed

4 files changed

+530
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ defmac = "0.2"
4949
quickcheck = { version = "0.9", default-features = false }
5050
approx = "0.4"
5151
itertools = { version = "0.10.0", default-features = false, features = ["use_std"] }
52+
matches = "0.1.8"
5253

5354
[features]
5455
default = ["std"]

0 commit comments

Comments
 (0)