3 pub trait Array2D: Index<usize> + Sized {
4 fn rows(&self) -> usize;
5 fn columns(&self) -> usize;
6 fn get<'a>(&'a self, y: usize, x: usize) -> Option<&'a <Self as Index<usize>>::Output> {
7 if y >= self.rows() || x >= self.columns() {
10 let i = y * self.columns() + x;
11 let indexer = &(*self as &dyn Index<usize, Output = <Self as Index<usize>>::Output>);
12 //~^ERROR non-primitive cast
13 Some(indexer.index(i))