diff options
author | metamuffin <metamuffin@disroot.org> | 2023-03-07 17:56:50 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-03-07 17:56:50 +0100 |
commit | 00f4bab2f1a1dcec9d2bf683b574dc0b9c599bcb (patch) | |
tree | c3f09431e5b1ea41e2201ab0dba906eb0fa5d30a /lvc/src/impls.rs | |
parent | 414990bb53f5c9e2028d42db46fa641fa606cd86 (diff) | |
download | video-codec-experiments-00f4bab2f1a1dcec9d2bf683b574dc0b9c599bcb.tar video-codec-experiments-00f4bab2f1a1dcec9d2bf683b574dc0b9c599bcb.tar.bz2 video-codec-experiments-00f4bab2f1a1dcec9d2bf683b574dc0b9c599bcb.tar.zst |
works well
Diffstat (limited to 'lvc/src/impls.rs')
-rw-r--r-- | lvc/src/impls.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lvc/src/impls.rs b/lvc/src/impls.rs index 0801361..00614c9 100644 --- a/lvc/src/impls.rs +++ b/lvc/src/impls.rs @@ -88,7 +88,10 @@ impl Index<P2> for Frame { type Output = Pixel; #[inline] fn index(&self, P2 { x, y }: P2) -> &Self::Output { - &self.pixels[x as usize + (y as usize * self.size.x as usize)] + &self + .pixels + .get(x as usize + (y as usize * self.size.x as usize)) + .unwrap_or(&Pixel { r: 0, g: 0, b: 0 }) } } impl IndexMut<P2> for Frame { @@ -97,3 +100,14 @@ impl IndexMut<P2> for Frame { &mut self.pixels[x as usize + (y as usize * self.size.x as usize)] } } + +pub trait ToArray { + type Output; + fn to_array(self) -> [Self::Output; 2]; +} +impl<A> ToArray for (A, A) { + type Output = A; + fn to_array(self) -> [A; 2] { + [self.0, self.1] + } +} |