Create a new [`ScalarBuffer`] from a [`Buffer`], and an `offset` and `length` in units of `T` # Panics This method will panic if `offset` or `len` would result in overflow `buffer` is not aligned to a multiple of `std::mem::align_of:: ` `bytes` is not large enough for the requested slice
(buffer: Buffer, offset: usize, len: usize)
| 87 | /// * `buffer` is not aligned to a multiple of `std::mem::align_of::<T>` |
| 88 | /// * `bytes` is not large enough for the requested slice |
| 89 | pub fn new(buffer: Buffer, offset: usize, len: usize) -> Self { |
| 90 | let size = std::mem::size_of::<T>(); |
| 91 | let byte_offset = offset.checked_mul(size).expect("offset overflow"); |
| 92 | let byte_len = len.checked_mul(size).expect("length overflow"); |
| 93 | buffer.slice_with_length(byte_offset, byte_len).into() |
| 94 | } |
| 95 | |
| 96 | /// Unsafe function to create a new [`ScalarBuffer`] from a [`Buffer`]. |
| 97 | /// Only use for testing purpose. |
nothing calls this directly
no test coverage detected