title: Restrict module function visibility in a project with library, binary and a module file
body: <p>I have a project with three files:</p>
  <ol>
  <li>Module file (<code>src/foo.rs</code>)</li>
  <li>Library file (<code>src/lib.rs</code>)</li>
  <li>Binary file (<code>src/main.rs</code>)</li>
  </ol>
  <p>I want to have public functions in the module file with visibility restricted to the library and binary files only.</p>
  <p>I have tried using <code>pub(crate)</code>, <code>pub(super)</code>, and the like but to no avail.</p>
  <p>I want to design the project structure in a way so that:</p>
  <ol>
  <li>Only <code>pub</code> functions in <code>lib.rs</code> can be called from outside while using it as a dependency crate.</li>
  <li>All the functions in <code>foo.rs</code> should be visible only to <code>lib.rs</code> and <code>main.rs</code>.</li>
  <li>All the functions in <code>main.rs</code> should be private.</li>
  </ol>
  <p>EDIT1: I want it because <code>pub(crate)</code> warns me of dead code while <code>pub</code> doesn't. I don't want any dead code inside the module. In the maintenance of large projects, it helps out quite a bit with debugging and refactoring.</p>
  <p>EDIT2: <a href="https://internals.rust-lang.org/t/restrict-module-function-visibility-in-a-project-with-library-binary-and-a-module-file/15801" rel="nofollow noreferrer">Rust Internals Thread</a></p>