Error code E0117
Only traits defined in the current crate can be implemented for arbitrary types.
Erroneous code example:
ⓘ
This error indicates a violation of one of Rust's orphan rules for trait implementations. The rule prohibits any implementation of a foreign trait (a trait defined in another crate) where
- the type that is implementing the trait is foreign
- all of the parameters being passed to the trait (if there are any) are also foreign.
To avoid this kind of error, ensure that at least one local type is referenced
by the impl
:
Alternatively, define a trait locally and implement that instead:
For information on the design of the orphan rules, see RFC 1023.