blob: 6d9794a94e5cdc2934f566db158b6eaf9bc30f53 [file] [log] [blame] [view] [edit]
# Using Structs to Structure Related Data
A _struct_, or _structure_, is a custom data type that lets you package together
and name multiple related values that make up a meaningful group. If youre
familiar with an object-oriented language, a _struct_ is like an objects data
attributes. In this chapter, well compare and contrast tuples with structs to
build on what you already know and demonstrate when structs are a better way to
group data.
Well demonstrate how to define and instantiate structs. Well discuss how to
define associated functions, especially the kind of associated functions called
_methods_, to specify behavior associated with a struct type. Structs and enums
(discussed in Chapter 6) are the building blocks for creating new types in your
programs domain to take full advantage of Rusts compile-time type checking.