Your index function actually calls itself which is obviously not what you want. One way around this would be to implement index on Matrix2x2 directly and then call that from the Index trait.
A quick example:
impl<T> Matrix2x2<T> {
pub fn new(data_input: [[T; 2]; 2]) -> Matrix2x2<T> {
Matrix2x2(data_input)
}
// implement the index function here.
pub fn index(&self, index: (usize, usize)) -> &T {
&self.0[index.0][index.1]
}
}
impl<T> Index<(usize, usize)> for Matrix2x2<T> {
type Output = T;
fn index(&self, index: (usize, usize)) -> &T {
// explicitly call the Maxtrix2s2 index function.
Matrix2x2::index(&self, index)
}
}