Use Literal formatting a bit less for the word "struct"

In these cases, we're using it more as an English concept (that we've
defined) and not a literal keyword.
This commit is contained in:
Carol (Nichols || Goulding) 2016-11-23 09:29:08 -05:00
parent 7d4201afe4
commit 0859cf22ef

View File

@ -61,7 +61,7 @@ wanted just this users email address, we can say `user1.email`.
To understand when we might want to use structs, lets write a program that
calculates the area of a rectangle. Well start off with single variable
bindings, then refactor our program until were using `struct`s instead.
bindings, then refactor our program until were using structs instead.
Lets make a new binary project with Cargo called *rectangles* that will take
the length and width of a rectangle specified in pixels and will calculate the
@ -154,8 +154,8 @@ in our code.
### Refactoring with Structs: Adding More Meaning
Here is where we bring in `struct`s. We can transform our tuple into a data
type with a name for the whole as well as names for the parts:
Here is where we bring in structs. We can transform our tuple into a data type
with a name for the whole as well as names for the parts:
Filename: src/main.rs
@ -181,8 +181,8 @@ fn area(rectangle: &Rectangle) -> u32 {
<!-- Will add ghosting & wingdings once we're in libreoffice /Carol -->
Here we've defined a `struct` and given it the name `Rectangle`. Inside the
`{}` we defined the fields to be `length` and `width`, both of which have type
Here weve defined a struct and given it the name `Rectangle`. Inside the `{}`
we defined the fields to be `length` and `width`, both of which have type
`u32`. Then in `main`, we create a particular instance of a `Rectangle` that
has a length of 50 and a width of 30.