Add #[inline] attribute to all fns which return SmallVec
When rustc fails to inline a `SmallVec` constructor, it can carry a significant performance cost: for example, if `SmallVec::<[i64; 128]>::from_iter(...)` fails to inline, it will perform an unnecessary 1kb memcpy.
I've recently been bitten by this when using `SmallVec` in a context where rustc seemed to be reluctant to perform inlining (a large fn with nested closures). Switching from `SmallVec::from_iter` to `SmallVec::new` and `push`, with a buffer size of 256 bytes, saved over 20ns per call. For larger buffers, `from_iter` carried a proportionally higher cost, even when the actual capacity in use didn't change.
Add support for constant generics
No breaking changes and no internal hacks. This PR only adds a feature to switch between implementations of the `Array` trait.
I personally think that this approach is pretty reasonable and should be at least considered for discussion.
Version 1.2.0
Changes in this release:
* `IntoIter` now implements `Debug` (#196).
* `smallvec!` macro is now easier to use in `no_std` contexts where the `vec!` macro isn't automatically imported (#198).
Changes in this release:
* `IntoIter` now implments `Debug` (#196).
* `smallvec!` macro is now easier to use in `no_std` contexts
where the `vec!` macro isn't automatically imported (#198).
Version 1.1.0
Changes in this release:
* Added new method `SmallVec::into_boxed_slice` (#190).
* Added new methods `IntoIter::as_slice` and `as_mut_slice` (#182).
* `IntoIter` now implements `Clone` (#192).
* Improved documentation and testing (#186, #189).
* Minor code cleanups (#176).
Also added a simple example to the README.
Changes in this release:
* Added new method `SmallVec::into_boxed_slice` (#190).
* Added new method `IntoIter::as_slice` (#182).
* `IntoIter` now implements `Clone` (#192).
* Improved documentation and testing (#186, #189).
* Minor code cleanups (#176).
Implement Clone for IntoIter<A> where A: Clone
Implemented code to fix#178. The commented impl can be uncommented once specialization is possible. Both impls were tested and passed the three added tests.
Implement into_boxed_slice() and doc-comment it.
Implements `into_boxed_slice()` as per suggestion in #184.
I didn't write tests, since all I did was to call an existing method of `SmallVec`, `into_vec()` to create a `Vec` from it and then call a method of `alloc::vec::Vec`, `into_boxed_slice()` on the resulting `Vec`. Thus, nothing in my code needs testing, since it is trivially offloading to other methods.
I didn't, however, find a test exercising `into_vec()`, however. That is maybe something I can do? If so, can I get some pointers to where I should look for example tests and where my tests should live?
EDIT: Never mind, I forgot that unit tests are in the same file, so I scrutinized smallvec_ops.rs to search for a test for `into_vec()` and couldn't find it.
Version 1.0.0
* Requires Rust 1.36 or later.
* [breaking change] Use `MaybeUninit` to avoid possible undefined behavior (#162, #170).
* [breaking change] The `drain` method now takes a range argument, just like the standard `Vec::drain` (#145).
* [breaking change] Remove the `unreachable` function and replace it with the new standard `unreachable_unchecked` function (#164).
* [breaking change] Use `no_std` by default. This crate depends only on `core` and `alloc` by default. If the optional `write` feature is enabled then it depends on `std` so that `SmallVec<[u8;_]>` can implement the `std::io::Write` trait (#173).
* Add support for 96-element small vectors, `SmallVec<[T; 96]>` (#163).
* Iterators now implement `FusedIterator` (#172).
* Indexing now uses the standard `SliceIndex` trait (#166).
* Remove the deprecated `VecLike` trait (#165).
* Use `NonNull` internally (#171).
* Add automatic fuzz testing and MIRI testing (#168, #162).
* Update syntax and formatting to Rust 2018 standard (#174, #167).
* [breaking change] Use `MaybeUninit` internally to avoid possible undefined behavior (#162, #170).
* [breaking change] The `drain` method now takes a range argument, just like the standard `Vec::drain` (#145).
* [breaking change] Remove the `unreachable` function and replace it with the new standard `unreachable_unchecked` function (#164).
* [breaking change] Use `no_std` by default. This crate depends only on `core` and `alloc` by default. If the optional `write` feature is enabled then it depends on `std` so that `SmallVec<[u8, _]>` can implement the `std::io::Write` trait (#173).
* Add support for 96-element small vectors, `SmallVec<[T; 96]>` (#163).
* Iterators now implement `FusedIterator` (#172).
* Indexing now uses the standard `SliceIndex` trait (#166).
* Remove the deprecated `VecLike` trait (#165).
* Use `NonNull` internally (#171).
* Add automatic fuzz testing and MIRI testing (#168, #162).
* Update syntax and formatting to Rust 2018 standard (#174, #167).
Add simple fuzzing
Add simple fuzzing
Add infrastructure to automatically run fuzzers in CI,
and implement a simple fuzzing test based on triggering all (most)
public APIs in a randimized way.
As far as I was able to try, it catches the previous unsoundness issues
in a matter of seconds. This can be tried by changing the `path = "../"` dependency to
`version = "=0.6.3"` etc. and running the fuzzer manually. (Note: You'll need
to tweak the `Cargo.lock` to allow downloading the yanked versions).
Add infrastructure to automatically run fuzzers in CI,
and implement a simple fuzzing test based on triggering all (most)
public APIs in a randimized way.
As far as I was able to try it catches the previous unsoundness issues
in a matter of seconds. This can be tried by changing the `path = "../"` dependency to
`version = "=0.6.3"` etc. and running the fuzzer manually. (Note: You'll need
to tweak the `Cargo.lock` to allow downloading the yanked versions).
Related to #124
Use no_std by default
Since `alloc` became stable, the `std` feature is only needed to enable `impl Write for SmallVec`, which most users of this crate do not need. This patch replaces the enabled-by-default `std` feature with a disabled-by-default `write` feature. This decreases the chance that users of this crate will accidentally depend on libstd when they don't need it.
The `std` feature is only needed to enable `impl Write for SmallVec`,
which most users of this crate do not need. This patch replaces the
enabled-by-default `std` feature with a disabled-by-default `write`
feature. This decreases the chance that users of this crate will
accidentally depend on libstd when they don't need it.