1 2 3 4 5 6 7 8 9 10 11 12 13 14
struct Point { x: f64, y: f64, } impl Point { fn new(x: f64, y: f64) -> Self { Self { x, y } } fn distance(&self) -> f64 { (self.x * self.x + self.y * self.y).sqrt() } }