safety-dance icon indicating copy to clipboard operation
safety-dance copied to clipboard

Audit arrayref

Open Shnatsel opened this issue 6 years ago • 4 comments

https://crates.io/crates/arrayref

Macros to take fixed-length slices of memory instead of regular slices. 5000 downloads/day.

Shnatsel avatar Nov 02 '19 13:11 Shnatsel

It seems the same can be accomplished in 100% safe Rust thanks to TryFrom implementation from arrays to slices.

Example of similar 100% safe code in action: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9d6e1d61835060f832ce1724becb1214

Shnatsel avatar Nov 02 '19 13:11 Shnatsel

The limitation is that the 100% safe approach only works for sizes up to 32, and will remain so until const generics are stabilized.

Shnatsel avatar Nov 02 '19 13:11 Shnatsel

Reported possibility of a safe implementation upstream: https://github.com/droundy/arrayref/issues/18

Shnatsel avatar Nov 02 '19 16:11 Shnatsel

Running miri should be a good way to validate the crate since most of what it's doing is not input-dependent.

Shnatsel avatar Nov 02 '19 16:11 Shnatsel