title: Is it possible to declare a variable in the conditional of an if expression in Rust?
body: <p>In Go, we can declare a variable inside the conditional of an <code>if</code> expression. This variable will be valid inside the <code>if</code> scope, and not outside of it. For example:</p>
  <pre class="lang-golang prettyprint-override"><code>func main() {
      if n := 4; n != 0 {
          fmt.Printf(&quot;%d is not zero&quot;, n)
      } else {
          fmt.Printf(&quot;%d is zero&quot;, n)
      }
  
      fmt.Printf(&quot;%d&quot;, n) // error, n doesn't exist here!
  }
  </code></pre>
  <p>Is there a similar syntax in Rust?</p>