Skip to content

Commit

Permalink
Clarify that in_bounds_index has unspecified behavior for invalid ind…
Browse files Browse the repository at this point in the history
…ices
  • Loading branch information
fintelia committed Sep 19, 2023
1 parent 52f5219 commit 4b4e26c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ impl SampleLayout {
/// Assumes that the image is backed by some sufficiently large buffer. Then computation can
/// not overflow as we could represent the maximum coordinate. Since overflow is defined either
/// way, this method can not be unsafe.
///
/// Behavior is *unspecified* if the index is out of bounds or this sample layout would require
/// a buffer larger than `isize::MAX` bytes.
pub fn in_bounds_index(&self, c: u8, x: u32, y: u32) -> usize {
let (c_stride, x_stride, y_stride) = self.strides_cwh();
(y as usize * y_stride) + (x as usize * x_stride) + (c as usize * c_stride)
Expand Down

0 comments on commit 4b4e26c

Please sign in to comment.