title: Why a borrowed error appears if I use a non mutable variable in various place of my code?
body: <p>I'm learning rust and I'm struggling to understand why the following code does not compile with some &quot;Error[E0505]: cannot move out of <code>req</code> because it is borrowed&quot; error on the req.into_body(). If I remove the println! or move it before the match, it runs.</p>
  <pre><code>async fn hello_world(req: Request&lt;Body&gt;) -&gt; Result&lt;Response&lt;Body&gt;, Infallible&gt; {
    let mut response = Response::new(Body::empty());
  
    let method = req.method();
    let path = req.uri().path();
  
    match (method, path) {
      (&amp;Method::GET, &quot;/&quot;) =&gt; {
        *response.body_mut() = Body::from(&quot;Try POSTing data to /echo&quot;);
      }
      (&amp;Method::POST, &quot;/echo&quot;) =&gt; {
        *response.body_mut() = req.into_body();
      }
      _ =&gt; {
        *response.status_mut() = StatusCode::NOT_FOUND;
      }
    };
    println!(&quot;{} {}&quot;, method, path);
  
    Ok(response)
  }
  </code></pre>
  <p>I understand some of the borrowing, but I don't understand why the position of the println changes anything, as I'm already defining non mutable variables that are used successfully in the match.</p>