This way we cover all users up to 256 at least. The reason these are not
enabled by default is that they slow down the compilation of the crate
by a factor of 2-3x.
In the test, test with Vec first to see how Rust implements panic
recovery while elements drop. If Vec drops all the elements, then we
test that arrayvec does too.
This should perform better in both release and debug mode.
NOTE: This is significant because it changes the drop order of the
elements, and how we handle panicking destructors. If just one of the
destructors panic during ArrayVec drop, clear or truncate, the rest of
the elements should still drop. If we encounter another panic during
that process, however, Rust will abort as usual for panic during
unwinding.
```
warning: the type of this value must be known in this context
--> src/lib.rs:312:32
|
312 | ptr::copy(p, p.offset(1), len - index);
| ^^^^^^
|
= note: #[warn(tyvar_behind_raw_pointer)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906>
```
Copy the required unreachable and debug assertion; saves us dependency
on odds.
We could also depend on crate unreachable, but that adds dep on
2 microcrates.
Instead of being vague about it, we can promise it.
We continue to be a bit vague in ArrayString::set_len. I don't see how
to add a char boundary check in ArrayString::set_len unfortunately.
It's a tricky issue, checking char boundaries requires reading the
memory of the string, and we don't even know if the user of set_len has
initialized that area of memory yet (but they hopefully did).