title: How do I pass a reference to mutable data in Rust?
body: <p>I want to create a mutable struct on the stack and mutate it from helper functions.</p>
  
  <pre><code>#[derive(Debug)]
  struct Game {
      score: u32,
  }
  
  fn addPoint(game: &amp;mut Game) {
      game.score += 1;
  }
  
  fn main() {
      let mut game = Game { score: 0 };
  
      println!("Initial game: {:?}", game);
  
      // This works:
      game.score += 1;
  
      // This gives a compile error:
      addPoint(&amp;game);
  
      println!("Final game:   {:?}", game);
  }
  </code></pre>
  
  <p>Trying to compile this gives:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
    --&gt; src/main.rs:19:14
     |
  19 |     addPoint(&amp;game);
     |              ^^^^^ types differ in mutability
     |
     = note: expected type `&amp;mut Game`
                found type `&amp;Game`
  </code></pre>
  
  <p>What am I doing wrong?</p>