changeset 14707 | 29dbe9ce8b7d |
parent 14355 | 31717e1436cd |
--- a/rust/vec2d/src/lib.rs Thu Mar 21 01:23:05 2019 +0300 +++ b/rust/vec2d/src/lib.rs Fri Mar 22 18:01:08 2019 +0200 @@ -95,6 +95,19 @@ let width = self.width(); self.data.chunks_exact_mut(width) } + + #[inline] + pub unsafe fn as_bytes(&self) -> &[u8] { + use std::{ + slice, + mem + }; + + slice::from_raw_parts( + self.data.as_ptr() as *const u8, + self.data.len() * mem::size_of::<T>(), + ) + } } impl<T: Copy> AsRef<[T]> for Vec2D<T> {