title: Explicit annotations of references vs values in rust
body: <p>So in Rust, one thing I am puzzled with is the type inference ability when it comes to a value vs a reference. For example,</p>
  
  <pre><code>fn main() {
      let s1 = String::from("h1");
      let s2 = &amp;s1;
      println!("string is {}", s1);
  } 
  </code></pre>
  
  <p>The borrow checker allows this to compile, but I am not sure why? Is <code>s2</code> here a value or is it being inferred as a reference to s1?</p>
  
  <p>In C++, initializing a new value via a reference would create a copy, unless that variable was explicitly declared as a reference:</p>
  
  <pre><code>#include &lt;string&gt;
  
  int main(int argc, char const* argv[]) {
      std::string s1("Hello");
      std::string&amp; s2 = s1; // reference
      std::string s3 = s2; // copy
  }
  </code></pre>
  
  <p>So in rust, my question is, does type inference also apply to reference vs value situations? If so, when is when required to explicitly declare variables as references?</p>