Skip to content
Snippets Groups Projects
Select Git revision
  • 9a6d3933953f923fc2292fb6aefd91664c8c18d9
  • main default protected
2 results

javafx-controls-21.0.2.jar

Blame
  • vec.rs 713 B
    use std::ops::{Add, Sub, Mul};
    
    #[derive(Debug, Clone, Copy)]
    pub struct Vector {
        x: i128,
        y: i128,
    }
    
    
    impl Vector {
        pub fn new(x: i128, y: i128) -> Vector {
            Vector { x, y }
        }
    }
    
    
    impl Add for Vector {
        type Output = Vector;
    
        fn add(self, rhs: Self) -> Vector {
            Vector {
                x: self.x + rhs.x,
                y: self.y + rhs.y,
            }
        }
    }
    
    impl Sub for Vector {
        type Output = Vector;
    
        fn sub(self, rhs: Self) -> Vector {
            Vector {
                x: self.x - rhs.x,
                y: self.y - rhs.y,
            }
        }
    }
    
    
    impl Mul for Vector {
        type Output = i128;
    
        fn mul(self, rhs: Self) -> i128 {
            self.x * rhs.x + self.y * rhs.y
        }
    }