extern crate type_eq; use type_eq::{Constrain, Has, TypeEq}; struct X; struct Y; struct Point { x: T, y: T } impl Has for Point { type Val = T; fn get

(&self) -> Self::Val where Constrain: TypeEq { self.x } } impl Has for Point { type Val = T; fn get

(&self) -> Self::Val where Constrain: TypeEq { self.y } } fn main() { let p = Point { x: 3, y: 5 }; assert_eq!(3, p.get::()); assert_eq!(5, p.get::()); }