Book description
Updated in 2024: A new version has been released that simplifies the programs used in the book, based on changes in the Rust language and crates since original publication. The code has been updated to reflect version 4 of the clap crate.
For several consecutive years, Rust has been voted "most loved programming language" in Stack Overflow's annual developer survey. This open source systems programming language is now used for everything from game engines and operating systems to browser components and virtual reality simulation engines. But Rust is also an incredibly complex language with a notoriously difficult learning curve.
Rather than focusing on the language as a whole, this guide teaches Rust using a single small, complete, focused program in each chapter. Author Ken Youens-Clark shows you how to start, write, and test each of these programs to create a finished product. You'll learn how to handle errors in Rust, read and write files, and use regular expressions, Rust types, structs, and more.
Discover how to:
- Use Rust's standard libraries and data types such as numbers, strings, vectors, structs, Options, and Results to create command-line programs
- Write and test Rust programs and functions
- Read and write files, including stdin, stdout, and stderr
- Document and validate command-line arguments
- Write programs that fail gracefully
- Parse raw and delimited text manually, using regular expressions and Rust crates
- Use and control randomness
Publisher resources
Table of contents
- Preface
- 1. Truth or Consequences
- 2. Test for Echo
- 3. On the Catwalk
- 4. Head Aches
- 5. Word to Your Mother
- 6. Den of Uniquity
- 7. Finders Keepers
- 8. Shave and a Haircut
- 9. Jack the Grepper
- 10. Boston Commons
-
11. Tailor Swyfte
- How tail Works
-
Getting Started
- Defining the Arguments
- Parsing and Validating the Command-Line Arguments
- Parsing Positive and Negative Numeric Arguments
- Using a Regular Expression to Match an Integer with an Optional Sign
- Processing the Files
- Counting the Total Lines and Bytes in a File
- Finding the Starting Line to Print
- Finding the Starting Byte to Print
- Testing the Program with Large Input Files
- Solution
- Going Further
- Summary
- 12. Fortunate Son
- 13. Rascalry
- 14. Elless Island
- Epilogue
- Index
- About the Author
Product information
- Title: Command-Line Rust
- Author(s):
- Release date: January 2022
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781098109431
You might also like
book
Rust for Rustaceans
For developers who’ve mastered the basics, this book is the next step on your way to …
book
Rust Atomics and Locks
The Rust programming language is extremely well suited for concurrency, and its ecosystem has many libraries …
book
Rust in Action
Rust in Action introduces the Rust programming language by exploring numerous systems programming concepts and techniques. …
book
Programming WebAssembly with Rust
WebAssembly fulfills the long-awaited promise of web technologies: fast code, type-safe at compile time, execution in …