Fix assertion about length/capacity in C API (#1736)

I recently saw some [errors] crop up in wasmtime-go's CI, so let's be
sure to convert to `Box<[T]>` which guarantees the length/capacity of
the vector are equal.

[errors]: https://github.com/bytecodealliance/wasmtime-go/runs/694744570
This commit is contained in:
Alex Crichton
2020-05-21 15:06:30 -05:00
committed by GitHub
parent e5635f4bc9
commit 036c8ec8c5

View File

@@ -67,8 +67,8 @@ macro_rules! declare_vecs {
}
impl From<Vec<$elem_ty>> for $name {
fn from(mut vec: Vec<$elem_ty>) -> Self {
assert_eq!(vec.len(), vec.capacity());
fn from(vec: Vec<$elem_ty>) -> Self {
let mut vec = vec.into_boxed_slice();
let result = $name {
size: vec.len(),
data: vec.as_mut_ptr(),