title: How do I access files in the src directory from files in my tests directory?
body: <p>I have a project layout that looks like the following:</p>
  
  <pre><code>src/
      int_rle.rs
      lib.rs
  tests/
      test_int_rle.rs
  </code></pre>
  
  <p>The project compiles with <code>cargo build</code>, but I am unable to run the test with <code>cargo test</code>. I get the error</p>
  
  <pre><code>error[E0432]: unresolved import `int_rle`. There is no `int_rle` in the crate root
   --&gt; tests/test_int_rle.rs:1:5
    |
  1 | use int_rle;
    |     ^^^^^^^
  
  error[E0433]: failed to resolve. Use of undeclared type or module `int_rle`
   --&gt; tests/test_int_rle.rs:7:9
    |
  7 |         int_rle::IntRle { values: vec![1, 2, 3] }
    |         ^^^^^^^^^^^^^^^ Use of undeclared type or module `int_rle`
  
  error: aborting due to 2 previous errors
  
  error: Could not compile `minimal_example_test_directories`.
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>// src/lib.rs
  pub mod int_rle;
  
  // src/int_rle.rs
  
  #[derive(Debug, PartialEq)]
  pub struct IntRle {
      pub values: Vec&lt;i32&gt;,
  }
  
  // tests/test_int_rle.rs
  use int_rle;
  
  #[cfg(test)]
  mod tests {
      #[test]
      fn it_works() {
          int_rle::IntRle { values: vec![1, 2, 3] }
      }
  }
  
  // Cargo.toml
  [package]
  name = "minimal_example_test_directories"
  version = "0.1.0"
  authors = ["Johann Gambolputty de von Ausfern ... von Hautkopft of Ulm"]
  
  [dependencies]
  </code></pre>
  
  <p>Related: <a href="https://stackoverflow.com/questions/17340985/how-do-i-compile-a-multi-file-crate-in-rust">How do I compile a multi-file crate in Rust?</a> (how to do it if the test and source files are in the same folder.)</p>