//@ run-pass #![allow(dead_code)] pub fn main() { let _id: &Mat2 = &Matrix::identity(1.0); } pub trait Index { fn get(&self, _: Index) -> Result { panic!() } } pub trait Dimensional: Index { } pub struct Mat2 { x: T } pub struct Vec2 { x: T } impl Dimensional> for Mat2 { } impl Index> for Mat2 { } impl Dimensional for Vec2 { } impl Index for Vec2 { } pub trait Matrix: Dimensional { fn identity(t:T) -> Self; } impl Matrix> for Mat2 { fn identity(t:T) -> Mat2 { Mat2{ x: t } } }