File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
% Structs
2
2
3
- Structs are a way of creating more complex datatypes . For example, if we were
3
+ Structs are a way of creating more complex data types . For example, if we were
4
4
doing calculations involving coordinates in 2D space, we would need both an ` x `
5
5
and a ` y ` value:
6
6
@@ -24,12 +24,12 @@ fn main() {
24
24
}
25
25
```
26
26
27
- There’s a lot going on here, so let’s break it down. We declare a struct with
28
- the ` struct ` keyword, and then with a name. By convention, structs begin with a
29
- capital letter and are also camel cased: ` PointInSpace ` , not ` Point_In_Space ` .
27
+ There’s a lot going on here, so let’s break it down. We declare a ` struct ` with
28
+ the ` struct ` keyword, and then with a name. By convention, ` struct ` s begin with
29
+ a capital letter and are camel cased: ` PointInSpace ` , not ` Point_In_Space ` .
30
30
31
31
We can create an instance of our struct via ` let ` , as usual, but we use a `key:
32
- value` style syntax to set each field. The order doesn' t need to be the same as
32
+ value` style syntax to set each field. The order doesn’ t need to be the same as
33
33
in the original declaration.
34
34
35
35
Finally, because fields have names, we can access the field through dot
You can’t perform that action at this time.
0 commit comments