Implement RenderResource for Box<T> (#1893)

Allows render resources to move data to the heap by boxing them. I did this as a workaround to #1892, but it seems like it'd be useful regardless. If not, feel free to close this PR.
This commit is contained in:
TehPers 2021-04-14 23:58:25 +00:00
parent d8392e7a3e
commit e0b52079da

View file

@ -166,6 +166,27 @@ impl_render_resource_bytes!(i64);
impl_render_resource_bytes!(f32);
impl_render_resource_bytes!(f64);
impl<T> RenderResource for Box<T>
where
T: RenderResource,
{
fn resource_type(&self) -> Option<RenderResourceType> {
self.as_ref().resource_type()
}
fn write_buffer_bytes(&self, buffer: &mut [u8]) {
self.as_ref().write_buffer_bytes(buffer);
}
fn buffer_byte_len(&self) -> Option<usize> {
self.as_ref().buffer_byte_len()
}
fn texture(&self) -> Option<&Handle<Texture>> {
self.as_ref().texture()
}
}
impl<T> RenderResource for Vec<T>
where
T: Sized + Byteable,