1use crate::Vector3;
2
3pub struct Vector2<T> {
5 one: T,
6 two: T
7}
8
9impl<T> Vector2<T> {
10 pub fn new(one: T, two: T) -> Self {
11 return Self {
12 one: one,
13 two: two
14 };
15 }
16}
17
18impl<T> Vector2<T> {
19 pub fn get_one(&self) -> &T {
20 return &self.one;
21 }
22
23 pub fn get_one_mut(&mut self) -> &mut T {
24 return &mut self.one;
25 }
26
27 pub fn get_two(&self) -> &T {
28 return &self.two;
29 }
30
31 pub fn get_two_mut(&mut self) -> &mut T {
32 return &mut self.two;
33 }
34}
35
36impl<T: Default> Default for Vector2<T> {
37 fn default() -> Self {
38 return Self {
39 one: T::default(),
40 two: T::default()
41 };
42 }
43}
44
45impl<T: Clone> Clone for Vector2<T> {
46 fn clone(&self) -> Self {
47 return Self {
48 one: self.one.clone(),
49 two: self.two.clone()
50 };
51 }
52}
53
54impl<T: Copy> Copy for Vector2<T> {}
55
56impl<T> Into<(T, T)> for Vector2<T> {
57 fn into(self) -> (T, T) {
58 return (self.one, self.two);
59 }
60}
61
62impl<T> Into<Vector2<T>> for (T, T) {
63 fn into(self) -> Vector2<T> {
64 return Vector2::new(self.0, self.1);
65 }
66}
67
68impl<T: PartialEq> PartialEq for Vector2<T> {
69 fn eq(&self, other: &Self) -> bool {
70 return self.one == other.one && self.two == other.two;
71 }
72
73 fn ne(&self, other: &Self) -> bool {
74 return !self.eq(other);
75 }
76}
77
78impl<T: Default> Into<Vector3<T>> for Vector2<T> {
79 fn into(self) -> Vector3<T> {
80 return Vector3::new(self.one, self.two, T::default());
81 }
82}