lex_lib/vec2f64.rs
1//! Vector2 f64.
2
3mod operators;
4
5/// Simple f64 Vector2.
6#[derive(Debug, Copy, Clone, PartialEq)]
7pub struct Vec2f64 {
8 /// X value.
9 pub x: f64,
10 /// Y value.
11 pub y: f64
12}
13
14impl Vec2f64 {
15 /// Creates a new [`Vec2f64`] with x and y defined.
16 ///
17 /// use `default()` for a 0 initialized.
18 pub fn new(x: f64, y: f64) -> 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 Vec2f64 {
34 /// Creates a new [`Vec2f64`] with x and y initialized with 0.0.
35 fn default() -> Self {
36 Self{
37 x: 0.,
38 y: 0.
39 }
40 }
41}