mod error;
use error::Error;
mod lib;
use lib::lib_function;
fn main() -> Result<(), Error>{
lib_function()?;
// ^ the trait `From<lib::error::Error>`
// is not implemented for `error::Error`
Err(Error{})
}```
error.rs
```rust
#[derive(Debug)]
pub struct Error;
#[path = "error.rs"]
mod error;
use error::Error;
pub fn lib_function() -> Result<(), Error>
{
Err(Error{})
}
I've been searching how to "import" different rs files and mod was the only thing I found. But the files don't realize that they are using the same type.
lib::error::Error vs (main)::error:Error
rror[E0277]: `?` couldn't convert the error to `error::Error`
--> src\main.rs:10:19
|
8 | fn main() -> Result<(), Error>{
| ----------------- expected `error::Error` because of this
9 |
10 | lib_function()?;
| ^ the trait `From<lib::error::Error>` is not implemented for `error::Error`