O'Reilly logo

Rust Essentials by Ivo Balbaert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Structuring Data and Matching Patterns

Until now we have only used simple data, but to do real programming, more composite and structured data values are needed. Among them are flexible arrays and tuples, enums, and structs that represent more object-like behavior, similar to that found in classical object-oriented languages. Options are another important type that are used to ensure that cases where no value is returned are accounted for. Then, we will look at pattern matching, which is another typical functional construct in Rust. However, we will start by looking more carefully at strings. We will cover the following topics:

  • Strings
  • Arrays, vectors, and slices
  • Tuples
  • Structs
  • Enums
  • Getting input from the console
  • Matching patterns

Strings ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required