本頁尚未翻譯,以下為英文原文。
#E0043: no such field
The type has no field of this name (or a tuple has no element at this index). Check the spelling against the type's definition.
nabi
struct P { x: i32; y: i32; }
let p = P { x: 1, y: 2 };
println(f"{p.z}");
error[E0043]: struct `P` has no field `z` --> main.nabi:4:12 | 4 | println(f"{p.z}"); | ^^^ | = help: available fields: `x`, `y`
Use a field the type has; the help lists them:
nabi
struct P { x: i32; y: i32; }
let p = P { x: 1, y: 2 };
println(f"{p.y}");
2
Related: E0044 missing field in a literal, E0046 no such method or associated item
Found a mistake? Edit this page on GitHub. Last updated