1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
use {V2, P2, V3, P3}; pub trait Into2d { type Target; fn into_2d(self) -> Self::Target; } impl Into2d for V3 { type Target = V2; fn into_2d(self) -> V2 { V2::new(self.x, self.y) } } impl Into2d for P3 { type Target = P2; fn into_2d(self) -> P2 { P2::new(self.x, self.y) } } pub trait Into3d { type Target; fn into_3d(self) -> Self::Target; } impl Into3d for V2 { type Target = V3; fn into_3d(self) -> V3 { V3::new(self.x, self.y, 0.0) } } impl Into3d for P2 { type Target = P3; fn into_3d(self) -> P3 { P3::new(self.x, self.y, 0.0) } }