Here is the situation. I have a project named project_name and it has this file hierarchy:
project_name
|-- src
| |-- main.rs
| |-- lib.rs
| `-- tree_node.rs
I declared struct TreeNode in tree_node.rs.
pub struct TreeNode { ... }
There is method using TreeNode in lib.rs:
mod tree_node;
use tree_node::TreeNode;
pub struct Solution {}
impl Solution {
pub fn invert_tree(root: TreeNode) -> TreeNode { ... }
}
But when I try to use method invert_tree in main.rs like this:
use project_name::Solution;
use tree_node::TreeNode;
mod tree_node;
fn main() {
let tree = TreeNode::new(1);
let result = Solution::invert_tree(tree);
}
I got an error:
expected struct `project_name::tree_node::TreeNode`, found struct
`tree_node::TreeNode`
Maybe I use incorrectly term method but I hope the main point is clear. What is wrong?