From 036c8ec8c506c190d7fbf3890d668c950e2493fd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 21 May 2020 15:06:30 -0500 Subject: [PATCH] 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 --- crates/c-api/src/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/c-api/src/vec.rs b/crates/c-api/src/vec.rs index 8a7d7395a2..2952e6553e 100644 --- a/crates/c-api/src/vec.rs +++ b/crates/c-api/src/vec.rs @@ -67,8 +67,8 @@ macro_rules! declare_vecs { } impl From> 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(),