2 Language Foundations
In this chapter:
- Getting to grips with Rust syntax
- Learning the fundamental types and data structures
- Building command line utilities
- Compiling programs
This chapter introduces you to the fundamentals of Rust programming. By the end of the chapter, you will be able to create command line utilities and should be able to get the gist of most Rust programs. We’ll be working through most of the language’s syntax, but deferring much of the detail about why things are how they are for later in the book.
Programmers who have experience with another programming language will benefit the most from this chapter. If you are an experienced Rust programmer, feel free to skim through it.
We will be building grep-lite
, a much stripped down version of the ubiquitous grep
utility. grep-lite
looks for patterns within text, printing lines that match. A simple program allows us to focus on the unique features of Rust.
Tip
Beginners Are Welcome
Rust’s community strives to be welcome and responsive to newcomers. At times, you may strike a mental pothole when you encounter terms such as “lifetime elision”, “hygienic macros”, “move semantics” and “algebraic data types” without context. Don’t be afraid to ask for help. The community is much more welcoming than these helpful, yet opaque, terms may suggest.