title: How to use one module from another module in a Rust cargo project?
body: <p>There's a lot of Rust <a href="https://www.google.ca/search?q=rust+use+module" rel="noreferrer">documentation</a> about using modules, but I haven't found an example of a Cargo binary that has multiple modules, with one module using another. My example has three files inside the src folder. Modules a and b are at the same level. One is not a submodule of another.</p>
  
  <p>main.rs:</p>
  
  <pre><code>mod a;
  
  fn main() {
      println!("Hello, world!");
      a::a();
  }
  </code></pre>
  
  <p>a.rs:</p>
  
  <pre><code>pub fn a() {
      println!("A");
      b::b();
  }
  </code></pre>
  
  <p>and b.rs:</p>
  
  <pre><code>pub fn b() {
      println!("B");
  }
  </code></pre>
  
  <p>I've tried variations of <code>use b</code> and <code>mod b</code> inside a.rs, but I cannot get this code to compile. If I try to use <code>use b</code>, for example, I get the following error:</p>
  
  <pre><code> --&gt; src/a.rs:1:5
    |
  1 | use b;
    |     ^ no `b` in the root. Did you mean to use `a`?
  </code></pre>
  
  <p>What's the right way to have Rust recognize that I want to use module b from module a inside a cargo app?</p>