Impl From<SqlBuilderError> for diesel::result::Error

Hi , i'm new in rust. I'm trying to implement From trait for two different types in different crates.
but i found this error.

impl From < SqlBuilderError >for diesel::result::Error {
| ^^^^^---------------------^^^^^---------------------^^^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| | | diesel::result::Error is not defined in the current crate
| | SqlBuilderError is not defined in the current crate
| impl doesn't use only types from inside the current crate

Trait implementations must obey the "orphan rules", which in loose terms say that either the trait or at least some of the types involved have to be local to the crate. Under the rules, this:

impl From<SqlBuilderError> for diesel::result::Error

is only legal in From's crate, in SqlBuilderError's crate, or in the diesel::result crate.

Perhaps what you need is a custom error type, and some implementations From both SqlBuilderError and diesel::result::Error.

2 Likes