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