1 Attempted to access a field on a primitive type.
3 Erroneous code example:
7 println!("{}", x.foo); // error: `{integer}` is a primitive type, therefore
11 Primitive types are the most basic types available in Rust and don't have
12 fields. To access data via named fields, struct types are used. Example:
15 // We declare struct called `Foo` containing two fields:
21 // We create an instance of this struct:
22 let variable = Foo { x: 0, y: -12 };
23 // And we can now access its fields:
24 println!("x: {}, y: {}", variable.x, variable.y);
27 For more information about [primitives] and [structs], take a look at the Book.
29 [primitives]: https://doc.rust-lang.org/book/ch03-02-data-types.html
30 [structs]: https://doc.rust-lang.org/book/ch05-00-structs.html