title: Why does Rust compile my project again with `cargo build --release` followed by `cargo run`?
body: <p><a href="https://doc.rust-lang.org/book/ch01-03-hello-cargo.html" rel="noreferrer">Rust documentation</a> teaches us that <code>cargo build</code> creates a binary file  after compiling, which we can execute with <code>cargo run</code>. <code>cargo run</code> will again compile the code if it notices any change after <code>cargo build</code> command is executed. It also says that <code>cargo build --release</code> command creates the final program, which will run faster.</p>
  
  <p>My question is, why is that when I do <code>cargo build --release</code>, it compiles the code, which is fine. But when I execute <code>cargo run</code>, it again compiles the code, even though I haven't changed any code since. It is working normally with <code>cargo build</code>, followed by <code>cargo run</code> i.e compiling one time with the former command.</p>
  
  <pre class="lang-none prettyprint-override"><code>naufil@naufil-Inspiron-7559:~/Desktop/rust/20April/variables$ cargo build
     Compiling variables v0.1.0 (/home/naufil/Desktop/rust/20April/variables)
      Finished dev [unoptimized + debuginfo] target(s) in 0.35s
  naufil@naufil-Inspiron-7559:~/Desktop/rust/20April/variables$ cargo run
      Finished dev [unoptimized + debuginfo] target(s) in 0.02s
       Running `target/debug/variables`
  Hello, world! 6
  naufil@naufil-Inspiron-7559:~/Desktop/rust/20April/variables$ cargo build --release
     Compiling variables v0.1.0 (/home/naufil/Desktop/rust/20April/variables)
      Finished release [optimized] target(s) in 0.34s
  naufil@naufil-Inspiron-7559:~/Desktop/rust/20April/variables$ cargo run
     Compiling variables v0.1.0 (/home/naufil/Desktop/rust/20April/variables)
      Finished dev [unoptimized + debuginfo] target(s) in 0.23s
       Running `target/debug/variables`
  Hello, world! 6
  </code></pre>