This is a nicer and simpler interface to expose, since the ref to uninit
array to pointer cast is not usable anyway (it's historic now, arrayvec
itself does not use it anymore).
The raw pointer walk did not do the right thing for ZST, because when
offsets are zero, the start and end pointer would be the same and the
loop ends before incrementing the length correctly.
This is very useful for generic code that may want to parse arbitrary
input string into arbitrary other types.
Limitations of the FromStr trait don't allow us to keep the original string slice
inside the CapacityError, unfortunately.
* '0.4' of https://github.com/bluss/arrayvec:
0.4.10
FIX: Remove unused Copy/Clone for MaybeUninit
FIX: Use repr(C) MaybeUninit after discussion with RalfJung
We have a recommendation from the unsafe-wg (no rule yet), that
repr(C) for unions should work this way, so that we can cast from the
union type to one of its fields.
We have a recommendation from the unsafe-wg (no rule yet), that
repr(C) for unions should work this way, so that we can cast from the
union type to one of its fields.
This is the "real" union solution, and ArrayString can use it since its
backing array is Copy. Unfortunately, we'll have to use the Copy bound
on the type, making it "viral" and visible in the user API.
Raw pointer taking should go through the MaybeUninit wrappers around the
arrays anyway, when it is partially uninitialized, which it often is.
The remaining .as_ptr() and .as_slice() methods on Array is only used
on a fully initialized array in ArrayString::from_byte_string
* '0.4' of https://github.com/bluss/arrayvec:
0.4.9
TEST: Add test that ensures the MaybeUninit impl is used on nightly
FIX: Remove use of uninitialized in ArrayString
FEAT: Implement a "MaybeUninit" and use it conditionally
TEST: Add test that Some(ArrayVec<[&_;_]>).is_some()
MAINT: Test the 0.4 branch in travis
We can't fix this properly (MaybeUninit with a union) until we change
the user visible API (we need to require that A: Copy.
As a temporary solution for arrayvec version 0.4.*, we use zeroed to
initialize an array of bytes, instead of using uninitialized. This may
have a negative performance impact, but the fix is to upgrade to future
arrayvec 0.5.
Use a build script to detect if we can use MaybeUninit or NoDrop.
Enabling unstable features automatically is not ideal, but since it's
a soundness issue we should do it.
Use a MaybeUninit-like union on nightly when we can. We use a feature
detection script in build.rs, so that we also go back to the fallback if
the unstable feature changes in an unexpected way.
We need to continue to use NoDrop for best working stable
implementation, but we eagerly use our union solution where we can,
currently only in nightlies.
Rustc feature probe code written by Josh Stone (cuviper),
taken from num-bigint.