Moving Trait Implementation to a Submodule, now it won't compile

I have code that compiled when it was all in the same executable source file. I created a Struct A and implemented a trait, Trait_A, on that class. Trait_A had a single function in it.

I wanted to move my new struct and its Trait_A implementation into a "submodule" by creating a file in the src directory called "a.rs" and adding pub mod a; to the lib.rs file. I then tried to move around the use statements until the warnings went away.

However, when I did this, I got the following error message:
1 error[E0277]: the trait bound Trait_A is not satisfied.

Though, none of the code that calls this code has changed. Why can't I do this, what is the problem, how does one do this naturally?

Can you share more of the code, or create a minimized test case? What module or crate is Trait_A defined in, and what is the parent of that module? What crate is being compiled when that compiler error is generated, and what is the file/line number that generates the error?

One possible situation is that both your library and your executable binary contain the code that defines Trait_A, which would result in two distinct traits that confusingly have the same name.

Ah ha! I think that was exactly what was happening. I'm making progress again. Thank you for your response.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.