title: Writing getter/setter properties in Rust
body: <p>I'm writing a very simple getter/setting model that I would like to start using in Rust for simplicity reasons using <code>struct</code> and <code>impl</code>.</p>
  
  <pre><code>struct Person {
      firstName: String,
      lastName: String,
  }
  
  impl Person {
      fn get_first_name(&amp;mut self) -&gt; String { return self.firstName; }
      fn get_last_name(&amp;mut self) -&gt; String {  return self.lastName; }
  
      fn set_first_name(&amp;mut self, x: String) { self.firstName = x; }
      fn set_last_name(&amp;mut self, x: String) { self.lastName = x; }
  
      fn default() -&gt; Person {
          Person {firstName: "".to_string(), lastName: "".to_string()}
      }
  }
  
  fn main() {
      let mut my_person : Person = Person{ ..Person::default() };
  
      my_person.set_first_name("John".to_string());
      my_person.set_last_name("Doe".to_string());
  
      println!("{}", my_person.firstName);
      println!("{}", my_person.lastName);
  }
  </code></pre>
  
  <p>When I run this snippet I get the following error.</p>
  
  <pre><code>src\main.rs:7:53: 7:57 error: cannot move out of borrowed content [E0507]
  src\main.rs:7     fn get_first_name(&amp;mut self) -&gt; String { return self.firstName; }
                                                                    ^~~~
  src\main.rs:8:53: 8:57 error: cannot move out of borrowed content [E0507]
  src\main.rs:8     fn get_last_name(&amp;mut self) -&gt; String {  return self.lastName; }
                                                                    ^~~~
  error: aborting due to 2 previous errors
  Could not compile `sandbox`.
  </code></pre>
  
  <p>Can someone point out the mistake to me since I'm very new to Rust?</p>
  
  <p>Tips on writing this snippet better would be accepted too. I'm always looking for easier/faster readability.</p>