Add support for arbitrary
This PR adds optional support for [Arbitrary](https://github.com/rust-fuzz/arbitrary/), which is helpful in fuzz testing. The implementation is nearly identical to Arbitrary's existing Vec implementation.
Test for drains that shift the tail, when inline
Previously, the test suite only had one trip through the tail-shifting
code in Drain::drop, and that is in the heap state.
In the current implementation, a tail-shifting drain while in the inline
state produces potentially dangerous aliasing which is currently
accepted by default Miri and rejected with -Ztrack-raw-pointers.
Adding this test case ensures that if this ever becomes an actual
problem it will be easy to find.
Previously, the test suite only had one trip through the tail-shifting
code in Drain::drop, and that is in the heap state.
In the current implementation, a tail-shifting drain while in the inline
state produces potentially dangerous aliasing which is currently
accepted by default Miri and rejected with -Ztrack-raw-pointers.
Adding this test case ensures that if this ever becomes an actual
problem it will be easy to find.
Version 1.6.0
Release notes:
* The `union` feature is now compatible with stable Rust 1.49 (#248, #247).
* Fixed warnings when compiling with Rust 1.51 nightly (#242, #246).
Release notes:
* The `union` feature is now compatible with stable Rust 1.49 (#248).
* Fixed warnings when compiling with Rust 1.51 nightly (#242, #246).
Wrap with ManuallyDrop so that the union feature works on 1.50
Per https://github.com/servo/rust-smallvec/issues/247#issuecomment-752794872
The unrelated diff was produced by rustfmt, which my editor runs automatically. I'm a bit surprised, usually when this produces a diff it's a big one. Do you want me to revert those lines?
Silence warnings about deprecated LayoutErr
This is renamed to LayoutError in Rust 1.51 and later, but we need to continue using the old name to support older versions of Rust.
Remove `min_const_generics` feature
Depends on https://github.com/rust-lang/rust/pull/79135.
If #240 is already under development and will be available before the 1.50 release, then feel free to close this PR. Otherwise, the feature removal will benefit upstream projects in the meanwhile.
Remove extraneous branch from push
`push` does two branches on the "smallness" of the `smallvec`: one before the reserve check and one after. LLVM doesn't seem to optimize the second branch away for the (very common) non-growing case. In addition, in the growing branch we know the memory will be on the heap, so no need to branch here.
On my machine, this improves `bench_push` from approx 300ns to 263ns (+/- 5 on both).
Version 1.5.0
Change log:
* Add the `append` method (#237).
* Add support for more array sizes between 17 and 31 (#234).
* Don't panic on deserialization errors (#238).
Change log:
* Add the `append` method (#237).
* Add support for more array sizes between 17 and 31 (#234).
* Don't panic on deserialization errors (#238).
Return allocation error in deserialize instead of panicking
There's no way to catch allocation errors since out of memory errors
cause an abort. Fail gracefully by returning the error instead of
panicking.
I happened upon this error when deserializing untrusted data with bincode. Bincode provides a byte limit bound but for sequences it's not possible to enforce this through serde since collection types like smallvec handle their own allocation.
Implement Array for all sizes <= 32
Most traits supported by arrays are fully supported for arrays in the Rust stdlib as for all sizes <= 32. I was surprised to find that `SmallVec<[T; 18]>` (I happen to know that 18 the maximum outside of obscure cases) isn't possible because smallvec::Array is not consistent with this pattern.
Of course, I don't actually need this — I can just choose another size, but it seems like it would be good/unsurprising to be a superset of libstd's choices here.
Version 1.4.2
Changelog:
* `insert_many` no longer leaks elements if the provided iterator panics (#213).
* The unstable `const_generics` and `specialization` features are updated to work with the most recent nightly Rust toolchain (#232).
* Internal code cleanup (#229, #231).
This PR also changes the `author` field in `Cargo.toml` to "The Servo Project Developers".
* `insert_many` no longer leaks elements if the provided iterator panics (#213).
* The unstable `const_generics` and `specialization` features are
updated to work with the most recent nightly Rust toolchain (#232).
* Internal code cleanup (#229, #231).