File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ A struct is a fairly straightforward type.
4
4
It's similar to classes in OOP languages, but there's no concept of inheritance or polymorphism here.
5
5
It simply allows you to group together related pieces of data - which can all be of different types - into a single name.
6
6
At a high level, we first define the struct by providing it's name, the names of the different fields and their associated types.
7
- We then create an instance of the struct by specifying the the values for each field.
7
+ We then create an instance of the struct by specifying the values for each field.
8
8
We can also add methods to a struct by defining functions within an ` impl ` block.
9
9
10
10
Let's create an input struct to group together our related input fields.
@@ -41,7 +41,8 @@ And all we have to do is create an instance of it in our `main` function:
41
41
...
42
42
```
43
43
44
- Pretty simple right? One neat modification we can make here is remove the key/value pair and just put a comma separated list of field names.
44
+ Pretty simple right?
45
+ One neat modification we can make here is remove the key/value pair and just put a comma separated list of field names.
45
46
We can do this anytime the field names match the variable names:
46
47
47
48
``` rust
You can’t perform that action at this time.
0 commit comments