error ambiguous-embed
Имя продвигается из двух встроенных типов.
What it means#
When two embedded types both provide a field or method with the same name, using that name through the outer type is ambiguous (§4.7). The conflict is reported at the use, and disappears if the outer type defines the name itself or the use is qualified.
Example#
data Animal { name: str }
data Pet { name: str }
data Dog { embed Animal; embed Pet }
fn main() {
let d = Dog{ Animal: Animal{ name: "a" }, Pet: Pet{ name: "p" } }
print(d.name) // <- ambiguous-embed
}error
ambiguous-embed
How to fix#
data Animal { name: str }
data Pet { name: str }
data Dog { embed Animal; embed Pet }
fn main() {
let d = Dog{ Animal: Animal{ name: "a" }, Pet: Pet{ name: "p" } }
print(d.Animal.name)
}Qualify the access with the embedded type (d.Animal.name), or declare the member in the outer type.