logo

Rust crates reviews

Cryptographically verifiable, distributed dependency reviews

crate: arrayvec

https://lib.rs/crates/arrayvec/

Add the last reviewed version to Cargo.toml / [dependencies]:

arrayvec = "0.7.2"

Filter reviews clicking on the numbers in the summary.

Full column names in tooltip hints: rating Negative, rating Neutral, rating Positive, rating Strong, thoroughness, understanding, reviews count.

Neg
Neu
Pos
Str
tho
und
rev
13
8
1
1
1
1
1
2
2
2
1
2
1
2
1
2
1
crate version
rating
date
reviewer
thoroughness, understanding
arrayvec 0.7.2
positive
2021-12-23
medium, low
alternative:
smallvec

The crate uses a lot of unsafe, although the conditions for safety seem to have been taken in consideration carefully.
The use of unsafe consists of: - Handling len/capacity where bounds are checked manually. This looks correct. - Handling unitialized memory for indices >= len. I don't know enough about it to judge correctness here - Handling utf8 conversions/assumptions. For example, the conversion from char to bytes. Correctness is checked for every byte here, so this is likely correct, too.

arrayvec 0.5.1
neutral
2019-12-22
medium, medium

Stack/value variable length arrays without heap fallback.

Pros:

  • Maybe sound?
  • Better than what you'll write.

Cons:

  • History of unsoundness (0.4.10 and earlier)
  • Disturbing amounts of unsafe

This version switched some slices possibly containing uninit (UB!) to use
pointers instead. This makes encode_utf8 unsafe, sadly.

DiffRatingNotes
.cargo_vcs_info.json+1
.gitignore+1
Cargo.lock+1Rust version bump?
Cargo.toml+1debug [profile.*]
Cargo.toml.orig+1debug [profile.*]
README.rst+1
*.{events,string_data,string_index}0Binary test files, unreviewed
src/array.rs+1Removed #[inline]
src/array_string.rs+1Added fn len, removed #[inline], use ptr instead of slice
src/chars.rs+1encode_utf8 is now sadly unsafe, more test coverage
src/lib.rs+1Inline tweaks, more (correct) ptr use, add as_*_ptr to match Vec (safe/sound)
arrayvec 0.5.0
neutral
2019-09-25
medium, medium

Stack/value variable length arrays without heap fallback.

Pros:

  • Maybe sound?
  • Better than what you'll write.

Cons:

  • History of unsoundness (0.4.10 and earlier)
  • Disturbing amounts of unsafe
DiffRatingNotes
.cargo_vs_info.json+1
.travis.yml+1MSRV bumped to 1.36.0, features tweaked.
Cargo.toml+1feature "serde-1" -> "serde", 2018 edition, drop cruft
Cargo.toml.orig+1
README.rst0"(not yet released)" no longer accurate.
benches/extend.rs+1+black_box
build.rs+1Dropped?
src/array.rs+1Improved safety docs, although could use more explaination of what relies on the invariants. () and bool indexing for 1/2-len arrays.
src/array_string.rs0mem::zeroed -> MaybeUninitCopy::uninitialized. Lots of Copy constraints, one transmute -> from_utf8_unchecked_mut (safer).
src/lib.rs0truncate now unsafe (but sound), new try_extend_from_slice is unsafe (but sound). ArrayVec::extend ZST handling is obtuse, would be unsound in C++, but I believe sound in Rust, maybe?
src/maybe_uninit.rs+1
src/maybe_uninit_nodrop.rs+1Removed
src/maybe_uninit_stable.rs+1Removed
src/range.rs+1Removed
tests/serde.rs+1
tests/tests.rs+1New test cases
arrayvec 0.4.11
positive
2019-07-22
low, medium
arrayvec 0.4.11
neutral
2019-07-28
high, medium

Probably sound as of 0.4.11 on Rust 1.36.0+?
Uses a disturbing amount of unsafe, but aside from uninitialized! use in ArrayVec 1.35 and earlier, it all at least appears to be correct after a careful reading.
Unlike smallvec, this doesn't fall back on the heap.
Better than whatever you'll write rolling your own, at least.

0.4.7 -> 0.4.8: IntoIter implemented Clone, unconcerning
0.4.8 -> 0.4.9: ArrayString initialized to 0, ArrayVec uses nightly MaybeUninit. Unfortunately stable still uses uninitialized!() so this is still negative.
0.4.9 -> 0.4.10: #[repr(C)], -Clone for MaybeUninit. Apparently I missed more possible unsoundness. Unsafe is hard.
0.4.10 -> 0.4.11: ArrayVec should now also be sound in Rust 1.36.0+, probably, maybe.

arrayvec 0.4.10
negative
2019-07-28
high, medium

Prefer 0.4.11 which at least starts using MaybeUninit instead of uninitialized!(), which is fundamentally unsound.
Uses a disturbing amount of unsafe, but aside from uninitialized, it all at least appears to be correct after a careful reading.
Unlike smallvec, this doesn't fall back on the heap.
Better than whatever you'll write rolling your own, at least.

0.4.7 -> 0.4.8: IntoIter implemented Clone, unconcerning
0.4.8 -> 0.4.9: ArrayString initialized to 0, ArrayVec uses nightly MaybeUninit. Unfortunately stable still uses uninitialized!() so this is still negative.
0.4.9 -> 0.4.10: #[repr(C)], -Clone for MaybeUninit. Apparently I missed more possible unsoundness. Unsafe is hard.

arrayvec 0.4.9
negative
2019-07-28
high, medium

Prefer 0.4.11 which at least starts using MaybeUninit instead of uninitialized!(), which is fundamentally unsound.
Uses a disturbing amount of unsafe, but aside from uninitialized, it all at least appears to be correct after a careful reading.
Unlike smallvec, this doesn't fall back on the heap.
Better than whatever you'll write rolling your own, at least.

0.4.7 -> 0.4.8: IntoIter implemented Clone, unconcerning
0.4.8 -> 0.4.9: ArrayString initialized to 0, ArrayVec uses nightly MaybeUninit. Unfortunately stable still uses uninitialized!() so this is still negative.

arrayvec 0.4.8
negative
2019-07-28
high, medium

Prefer 0.4.11 which at least starts using MaybeUninit instead of uninitialized!(), which is fundamentally unsound.
Uses a disturbing amount of unsafe, but aside from uninitialized, it all at least appears to be correct after a careful reading.
Unlike smallvec, this doesn't fall back on the heap.
Better than whatever you'll write rolling your own, at least.

See 0.4.7 for base review. Diffed 0.4.7 -> 0.4.8, no concerning changes.

arrayvec 0.4.7
negative
2019-07-28
high, medium

Prefer 0.4.11 which at least starts using MaybeUninit instead of uninitialized!(), which is fundamentally unsound.
Uses a disturbing amount of unsafe, but aside from uninitialized, it all at least appears to be correct after a careful reading.
Unlike smallvec, this doesn't fall back on the heap.
Better than whatever you'll write rolling your own, at least.

Detail

FileRatingNotes
benches/arraystring.rs+1
benches/extend.rs+1
src/array_string.rs0lots of unsafe, but I think sound
src/array.rs0fix_array_impl! hides unsafe, but not misused nor public
src/char.rs+1Relied upon for soundness... thoroughly checked against https://en.wikipedia.org/wiki/UTF-8
src/errors.rs+1
src/lib.rs0lots of unsafe, but I think sound
src/range.rs+1
tests/serde.rs+1
tests/tests.rs+1
.gitignore+1
.travis.yml+1
Cargo.toml+1
Cargo.toml.orig+1
custom.css+1
LICENSE-APACHE+1
LICENSE-MIT+1
README.rst+1
OtherRatingNotes
unsafe-1Overused
fs+1Unused
docs+1
tests0Good coverage... not seeing any fuzz testing for all this unsafe though.

src/array_string.rs

OK

LineNotes
56unsafe - new_array ~ uninitialized, Array is an unsafe trait though so only implement it if this is sound...?
95No CapacityError? Inconsistent vs from...
160unsafe { ... } - looks correct
213unsafe { ... } - looks correct
216could be a slice copy instead
245unsafe { ... } - looks correct
271unsafe { ... } - looks correct
307unsafe { ... } - looks correct
318unsafe { ... } - looks correct
331unsafe fn - decent docs, looks correct, should be more explicit about uninitialized though
342unsafe fn - needs better docs, but looks correct
351unsafe { ... } - looks correct
361unsafe { ... } - scary transmute, but just from &mut [u8] to &mut str. stdlib from_utf8_unchecked does equivalent pointer casts

src/array.rs

LineNotes
80Aieee!
132unsafe { ... } - not sure this is sound for bools etc.
214unsafe { ... } - looks correct
246unsafe fn - exactly as spceified
306unsafe { ... } - looks correct
340unsafe { ... } - looks correct
511unsafe fn - exactly as specified
552unsafe { ... } - scary as heck... but Drain should keep self borrowed long enough, at least.
575unsafe { ... } - looks correct
604unsafe { ... } - looks correct
614unsafe { ... } - looks correct
707unsafe { ... } - looks correct. Size could be reduced, relies on IntoIter's custom drop not dropping copied elements due to the index increment to avoid double drops.
724unsafe { ... } - looks correct. Size could be reduced, relies on IntoIter's custom drop not dropping copied elements due to the length decrement to avoid double drops.
740unsafe { ... } - looks correct. Implements the aforementioned IntoIter custom drop.
764unsafe Sync - I believe this is OK.
765unsafe Send - I believe this is OK.
775unsafe { ... } - looks correct. Relies on set_len already being truncated to avoid double drops.
793unsafe { ... } - looks correct. Relies on set_len already being truncated to avoid double drops.
809necessary to aovid memory leaks
812unsafe { ... } - looks correct.
851unsafe { ... } - looks correct.
1008unsafe { ... } - looks correct.

© bestia.dev 2023, MIT License, Version: 2023.608.1636

Open source repository for this web app: https://github.com/bestia-dev/cargo_crev_web/