I'm having a bit of a headache trying to use traits defined in separate files to the implementation and was hoping somebody could point out where I am going wrong.
My file structure is this
main.rs file1.rs thing.rs Contents of main.rs
mod file1; mod thing; fn main() { let item : Box<dyn file1::Trait1> = Box::new(thing::Thing {}); } file1.rs
pub trait Trait1 { } thing.rs
mod file1 { include!("file1.rs"); } pub struct Thing { } impl file1::Trait1 for Thing { } The error on compilation is:
error[E0277]: the trait bound `thing::Thing: file1::Trait1` is not satisfied --> src/main.rs:9:41 | 9 | let item : Box<dyn file1::Trait1> = Box::new(thing::Thing {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `file1::Trait1` is not implemented for `thing::Thing` | = note: required for the cast to the object type `dyn file1::Trait1` As far as I can tell file1::Trait1 is implemented. If not, what have I actually implemented?