Commit ad8be54b authored by Romain Vimont's avatar Romain Vimont Committed by Thomas Daede

Implement operator[] for PlaneMutSlice

Implement traits Index and IndexMut to access PlaneMutSlice rows as if
it was a two-dimensional array.

Thay way, we can write:

    plane_slice[8][8] = 1;
    let row = &mut plane_slice[5];
    row[3] = 42;
parent c0e970f3
......@@ -10,7 +10,7 @@
use std::iter::FusedIterator;
use std::fmt::{Debug, Display, Formatter};
use std::mem;
use std::ops::{Index, Range};
use std::ops::{Index, IndexMut, Range};
use crate::util::*;
......@@ -517,3 +517,16 @@ impl<'a, T: Pixel> PlaneMutSlice<'a, T> {[new_y * self.plane.cfg.stride + new_x]
impl<'a, T: Pixel> Index<usize> for PlaneMutSlice<'a, T> {
type Output = [T];
fn index(&self, index: usize) -> &Self::Output {
impl<'a, T: Pixel> IndexMut<usize> for PlaneMutSlice<'a, T> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment