Ad
Code
Diff
  • struct Person {
      first_name: String,
      last_name: String,
    }
    
    impl Person {
      fn greet(&self) -> String {
        format!("Hello, my name is {} {}", self.first_name, self.last_name)
      }
    }
    fn person_builder(first_name: &str, last_name: &str) -> Person {
        Person { first_name: first_name.to_owned(), last_name: last_name.to_owned() }
    }
    • // Code is in the preload
    • struct Person {
    • first_name: String,
    • last_name: String,
    • }
    • impl Person {
    • fn greet(&self) -> String {
    • format!("Hello, my name is {} {}", self.first_name, self.last_name)
    • }
    • }
    • fn person_builder(first_name: &str, last_name: &str) -> Person {
    • Person { first_name: first_name.into(), last_name: last_name.into() }
    • Person { first_name: first_name.to_owned(), last_name: last_name.to_owned() }
    • }