Skip to content

Instantly share code, notes, and snippets.

@Steboss89
Created June 9, 2021 08:41
Show Gist options
  • Save Steboss89/686610342712a7b73b42748edd752bc7 to your computer and use it in GitHub Desktop.
Save Steboss89/686610342712a7b73b42748edd752bc7 to your computer and use it in GitHub Desktop.
impl
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