OxL Reference

error impl-foreign-type

error Standard: [§4.5]

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#

oxl✓ checked in CI
impl str {
  fn shout() -> str => "!"      // <- impl-foreign-type (str belongs to std)
}
error
impl-foreign-type

How to fix#

oxl✓ checked in CI
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.

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides