lex_lib/vec2i32.rs
1//! Vector2 i32.
2
3mod operators;
4
5/// A simple i32 Vector2.
6#[derive(Debug, Copy, Clone, PartialEq, Eq)]
7pub struct Vec2i32 {
8 /// X value.
9 pub x: i32,
10 /// Y value.
11 pub y: i32
12}
13
14impl Vec2i32 {
15 /// Creates a new [`Vec2i32`] with x and y defined.
16 ///
17 /// use `default()` for a 0 initialized.
18 pub fn new(x: i32, y: i32) -> Self {
19 Self{
20 x,
21 y
22 }
23 }
24
25 /// Puts x into y and y into x
26 pub fn flip(&mut self){
27 let tmp = self.x;
28 self.x = self.y;
29 self.y = tmp;
30 }
31}
32
33impl Default for Vec2i32 {
34 /// Creates a new [`Vec2i32`] with x and y initialized with 0.
35 fn default() -> Self {
36 Self{
37 x: 0,
38 y: 0
39 }
40 }
41}