Add comment regarding avoiding panics

This commit is contained in:
andrews05 2024-03-29 09:00:03 +13:00 committed by GitHub
parent 5aebb31531
commit d53f192f94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,6 +27,8 @@ impl<'a> Iterator for ScanLines<'a> {
let (len, pass, num_pixels) = self.iter.next()?; let (len, pass, num_pixels) = self.iter.next()?;
debug_assert!(self.raw_data.len() >= len); debug_assert!(self.raw_data.len() >= len);
debug_assert!(!self.has_filter || len > 1); debug_assert!(!self.has_filter || len > 1);
// The data length should always be correct here but this check assures
// the compiler that it doesn't need to account for a potential panic
if self.raw_data.len() < len { if self.raw_data.len() < len {
return None; return None;
} }