Give structs a bit more motivation

they deserve it
This commit is contained in:
Carol (Nichols || Goulding) 2016-07-21 20:58:04 -04:00
parent ec3939fb73
commit f7103f86b3

View File

@ -1,7 +1,12 @@
# Structs
`struct`s give us the ability to package up multiple values and
keep them in one related structure.
`struct`s, short for "structures", give us the ability to name and package
together multiple related values that make up a meaningful group. If you come
from an object-oriented language, `struct`s are like an object's data
attributes. `structs`, along with `enum`s that we talked about in the last
chapter, are the building blocks you can use in Rust to create new types in
your program's domain in order to take full advantage of Rust's compile-time
type checking.
Lets write a program which calculates the distance between two points.
Well start off with single variable bindings, and then refactor it to