// Rust does not have class
// Rust have `struct` and `impl`, they have the same class performance
struct Person {
name: String,
age: usize
}
impl Person {
// This associated function have the same `constrator` performance
fn new(name: String, age: usize) -> Self {
return Self {name, age};
}
fn get_name(&self) -> String {
return self.name;
}
fn change_name(&mut self, new_name: String) -> () {
self.name = new_name;
}
}