title: How to resolve "unresolved import" in Rust when using VS Code?
body: <p>I'm fairly new to rust and have been following the official book that they provide on their site. During chapter 2 they tell you to import a &quot;Rand&quot; cargo which I did. However, when I try to run my code directly through VS Code I get an error saying &quot;unresolved import <code>rand</code>&quot;. When I run it through command prompt, everything works fine. I've already tried every solution suggested here: <a href="https://github.com/rust-lang/rls-vscode/issues/513" rel="nofollow noreferrer">https://github.com/rust-lang/rls-vscode/issues/513</a> and nothing seemed to have worked. Extensions that I'm using:</p>
  <ul>
  <li>Better TOML</li>
  <li>Cargo</li>
  <li>Code Runner</li>
  <li>Rust (rls)</li>
  <li>Rust Assist</li>
  <li>vsc-rustfmt</li>
  <li>vscode-rust-syntax</li>
  </ul>
  <p>Has anyone else ran into a similar problem or a know a solution? Thank you!</p>
  <p>Edit: My Cargo.TOML looks like this:</p>
  <pre class="lang-toml prettyprint-override"><code>[package]
  name = &quot;guessing_game&quot;
  version = &quot;0.1.0&quot;
  authors = [&quot;Name &lt;MyNameHere@gmail.com&gt;&quot;]
  edition = &quot;2018&quot;
  
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  
  [dependencies]
  rand = &quot;0.6.0&quot;
  </code></pre>
  <p>Edit 2: my main.rs file looks like this:</p>
  <pre><code>use rand::Rng;
  use std::io;
  use std::cmp::Ordering;
  
  fn main()
  {
      println!(&quot;Guess the number!&quot;);
      let secret_number = rand::thread_rng().gen_range(1, 101);
      loop
      {
          println!(&quot;Please input your guess!&quot;);
          let mut guess = String::new();
          io::stdin().read_line(&amp;mut guess).expect(&quot;Failed to read line!&quot;);
          let guess: u32 = match guess.trim().parse()
          {
              Ok(num) =&gt; num,
              Err(_) =&gt; continue,
          };
          println!(&quot;Your guess {}&quot;, guess);
          match guess.cmp(&amp;secret_number)
          {
              Ordering::Less =&gt; println!(&quot;Too small!&quot;),
              Ordering::Greater =&gt; println!(&quot;Too big!&quot;),
              Ordering::Equal =&gt;
              {
                  println!(&quot;You win!&quot;);
                  break;
              }
          }
      }
  }
  </code></pre>