title: How do I use structs declared in other modules in main.rs?
body: <p>Here is the situation. I have a project named <strong>project_name</strong> and it has this file hierarchy:</p>
  
  <pre class="lang-none prettyprint-override"><code>project_name
  |-- src
  |   |-- main.rs
  |   |-- lib.rs
  |   `-- tree_node.rs
  </code></pre>
  
  <p>I declared struct <strong>TreeNode</strong> in tree_node.rs.</p>
  
  <pre><code>pub struct TreeNode { ... }
  </code></pre>
  
  <p>There is method using <strong>TreeNode</strong> in <strong>lib.rs</strong>:</p>
  
  <pre><code>mod tree_node;
  
  use tree_node::TreeNode;
  
  pub struct Solution {}
  
  impl Solution {
      pub fn invert_tree(root: TreeNode) -&gt; TreeNode { ... }
  }
  </code></pre>
  
  <p>But when I try to use method <strong>invert_tree</strong> in <strong>main.rs</strong> like this:</p>
  
  <pre><code>use project_name::Solution;
  use tree_node::TreeNode;
  
  mod tree_node;
  
  fn main() {
      let tree = TreeNode::new(1);
      let result = Solution::invert_tree(tree);
  }
  </code></pre>
  
  <p>I got an error: </p>
  
  <pre class="lang-none prettyprint-override"><code>expected struct `project_name::tree_node::TreeNode`, found struct
  `tree_node::TreeNode`
  </code></pre>
  
  <p>Maybe I use incorrectly term <strong>method</strong> but I hope the main point is clear. What is wrong?</p>