xxxxxxxxxx
struct Point {
x: f64,
y: f64
}
impl Point {
//associated function (can be used for constructors)
fn origin() -> Point {
Point { x: 0.0, y: 0.0 }
}
//new is usually used for constructors
fn new(x: f64, y: f64) -> Point {
Point { x: x, y: y }
}
// `&self` is sugar for `self: &Self` (caps lock Self is type)
fn move_up(&self) {
self.y += 5;
}
}