Created
June 9, 2021 08:41
-
-
Save Steboss89/686610342712a7b73b42748edd752bc7 to your computer and use it in GitHub Desktop.
impl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person { | |
name: String, // NB there's a comma here | |
surname: String, | |
age: u32 | |
} | |
impl Person{ | |
// method to get the person | |
fn who_are_you(&self){ | |
println!("This person's name is {} surname {} and age {}", self.name, self.surname, self.age) | |
} | |
// in main you can define a new Person | |
// then call Person.who_are_you() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment