error impl-foreign-type
What it means#
An inherent impl T { ... } MUST be in the package that declared T (§4.5). Adding methods to a standard or third-party type from outside would let two packages define clashing methods.
Example#
impl str {
fn shout() -> str => "!" // <- impl-foreign-type (str belongs to std)
}error
impl-foreign-type
How to fix#
interface Shout { fn shout() -> str }
impl Shout for str {
fn shout() -> str => "!"
}Declare your own interface and implement it for the foreign type: impl I for T is allowed when I or T is declared in your package. Alternatively wrap the type in your own data or distinct type.