We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 576efaf + 87de92e commit a0377dcCopy full SHA for a0377dc
examples/custom_types/structs/structs.rs
@@ -1,3 +1,9 @@
1
+#[derive(Debug)]
2
+struct Person<'a> {
3
+ name: &'a str,
4
+ age: u8
5
+}
6
+
7
// A unit struct
8
struct Nil;
9
@@ -18,6 +24,15 @@ struct Rectangle {
18
24
}
19
25
20
26
fn main() {
27
+ // Create struct with field init shorthand
28
+ let name = "Peter";
29
+ let age = 27;
30
+ let peter = Person { name, age };
31
32
+ // Print debug struct
33
+ println!("{:?}", peter);
34
35
21
36
// Instantiate a `Point`
22
37
let point: Point = Point { x: 0.3, y: 0.4 };
23
38
0 commit comments