1 // revisions: lib usage
2 //[lib] compile-flags: --crate-type=lib
9 fn from_values(x: Self::ScalarType, y: Self::ScalarType) -> Self
13 fn x(&self) -> Self::ScalarType;
14 fn y(&self) -> Self::ScalarType;
17 impl<T> Sub for dyn Vector2<ScalarType = T>
20 (dyn Vector2<ScalarType = T>): Sized,
22 type Output = dyn Vector2<ScalarType = T>;
24 fn sub(self, rhs: Self) -> Self::Output {
25 Self::from_values(self.x() - rhs.x(), self.y() - rhs.y())
34 impl Vector2 for Vec2 {
35 type ScalarType = i32;
37 fn from_values(x: Self::ScalarType, y: Self::ScalarType) -> Self
44 fn x(&self) -> Self::ScalarType {
47 fn y(&self) -> Self::ScalarType {
54 let hey: Box<dyn Vector2<ScalarType = i32>> = Box::new(Vec2 { x: 1, y: 2 });
55 let word: Box<dyn Vector2<ScalarType = i32>> = Box::new(Vec2 { x: 1, y: 2 });
57 let bar = *hey - *word;
58 //[usage]~^ ERROR cannot subtract