This commit is contained in:
bendn 2024-01-23 08:55:11 +07:00
parent 9210b2500f
commit 0e49a8066c
No known key found for this signature in database
GPG key ID: 0D9D3A2A3B2A93D6

View file

@ -438,7 +438,7 @@ impl<T, const CHANNELS: usize> Image<T, CHANNELS> {
T: AsRef<[U]>,
{
// SAFETY: 0 sized images illegal
unsafe { assert_unchecked(self.len() > CHANNELS) };
unsafe { assert_unchecked(self.len() >= CHANNELS) };
// SAFETY: no half pixels!
unsafe { assert_unchecked(self.len() % CHANNELS == 0) };
self.buffer().as_ref().array_chunks::<CHANNELS>()
@ -529,7 +529,7 @@ impl<T: AsMut<[u8]> + AsRef<[u8]>, const CHANNELS: usize> Image<T, CHANNELS> {
/// Returns a iterator over every pixel, mutably
pub fn chunked_mut(&mut self) -> impl Iterator<Item = &mut [u8; CHANNELS]> {
// SAFETY: 0 sized images are not allowed
unsafe { assert_unchecked(self.len() > CHANNELS) };
unsafe { assert_unchecked(self.len() >= CHANNELS) };
// SAFETY: buffer cannot have half pixels
unsafe { assert_unchecked(self.len() % CHANNELS == 0) };
self.buffer.as_mut().array_chunks_mut::<CHANNELS>()