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.
1 parent b656f3c commit 580f118Copy full SHA for 580f118
src/custom_types/structs.md
@@ -37,6 +37,12 @@ struct Rectangle {
37
bottom_right: Point,
38
}
39
40
+// Struct with named fields can have default values
41
+struct Command {
42
+ command: String,
43
+ arguments: Vec<String> = Vec::new(),
44
+}
45
+
46
fn main() {
47
// Create struct with field init shorthand
48
let name = String::from("Peter");
@@ -70,6 +76,9 @@ fn main() {
70
76
bottom_right: bottom_right,
71
77
};
72
78
79
+ // Instantiate a `Command` with only required fields specified
80
+ let command = Command { command: String::from("ls"), .. };
81
73
82
// Instantiate a unit struct
74
83
let _unit = Unit;
75
84
0 commit comments