diff --git a/vulkano/src/pipeline/graphics/vertex_input/collection.rs b/vulkano/src/pipeline/graphics/vertex_input/collection.rs index b5354b66..442af664 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/collection.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/collection.rs @@ -1,5 +1,5 @@ use crate::buffer::Subbuffer; -use std::mem; +use std::mem::{self, ManuallyDrop}; /// A collection of vertex buffers. pub trait VertexBuffersCollection { @@ -32,8 +32,13 @@ impl VertexBuffersCollection for Vec> { mem::align_of::>(), ); + let mut this = ManuallyDrop::new(self); + let cap = this.capacity(); + let len = this.len(); + let ptr = this.as_mut_ptr(); + // SAFETY: All `Subbuffer`s share the same layout. - unsafe { mem::transmute::>, Vec>>(self) } + unsafe { Vec::from_raw_parts(ptr.cast(), len, cap) } } }