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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Test: std::ops traits should map to Rust's std::ops, NOT windjammer_runtime
use std::ops::Add
use std::ops::Sub
use std::ops::Mul
use std::ops::Div
struct Vec2 {
x: f32,
y: f32,
}
impl Add for Vec2 {
type Output = Vec2
fn add(self, other: Vec2) -> Vec2 {
Vec2 { x: self.x + other.x, y: self.y + other.y }
}
}
fn main() {
let v1 = Vec2 { x: 1.0, y: 2.0 }
let v2 = Vec2 { x: 3.0, y: 4.0 }
let v3 = v1 + v2
println!("v3 = ({}, {})", v3.x, v3.y)
}