Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Rust Programming Cookbook

You're reading from   Rust Programming Cookbook Explore the latest features of Rust 2018 for building fast and secure apps

Arrow left icon
Product type Paperback
Published in Oct 2019
Publisher Packt
ISBN-13 9781789530667
Length 444 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Claus Matzinger Claus Matzinger
Author Profile Icon Claus Matzinger
Claus Matzinger
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Starting Off with Rust 2. Going Further with Advanced Rust FREE CHAPTER 3. Managing Projects with Cargo 4. Fearless Concurrency 5. Handling Errors and Other Results 6. Expressing Yourself with Macros 7. Integrating Rust with Other Languages 8. Safe Programming for the Web 9. Systems Programming Made Easy 10. Getting Practical with Rust 11. Other Books You May Enjoy

What this book covers

Chapter 1, Starting off with Rust, covers how to set up Rust toolchains on your computer and the fundamental constructs of the language. These range from writing tests and benchmarks to language constructs such as loops, if expressions, traits, and structs.

Chapter 2, Going Further with Advanced Rust, answers questions about more in-depth features of the language as well as patterns for creating meaningful programs. Topics include borrowing and ownership in complex scenarios, the Option type, pattern matching, generics, explicit lifetimes, and enums.

Chapter 3, Managing Projects with Cargo, uses the cargo tool to manage additional crates, extensions, projects, and tests. You will find recipes that empower you to work on larger projects and solve challenges faced in managing them.

Chapter 4, Fearless Concurrency, goes into some best practices and recipes to build safe, fast programs. In addition to this, popular libraries such as Rayon are presented as we demonstrate that Rust is a great language for doing all kinds of concurrent tasks.

Chapter 5, Handling Errors and Other Results, explains how Rust uses the Result type and panics to perform error handling, integrating most failure cases into a regular workflow that needs to be treated. This chapter shows applicable patterns and best practices around avoiding unexpected crashes and unnecessary complexity.

Chapter 6, Expressing Yourself with Macros, explains how Rust's unique macro system extends the functionality of programs before compilation—in a type safe way. These macros can be implemented for many possible custom scenarios, and many crates use this ability. This chapter is all about creating useful macros to make your life easier and your programs safer.

Chapter 7, Integrating Rust with Other Languages, uses and works with different binary units and languages from within Rust in order to port legacy software or benefit from better SDKs. This is realized mostly through the Foreign Function Interface (FFI), which enables quick and easy integration with other native binaries. On top of that, it is possible to publish to npm (the Node.js package repository) from Rust using WebAssembly. These and other things are discussed in this chapter.

Chapter 8, Safe Programming for the Web, uses a state-of-the-art web framework to show the fundamentals of web programming – actix-web, which showcases an actor-based approach to handling requests, in productive use at Microsoft.

Chapter 9, Systems Programming Made Easy, explains how Rust is a great choice for running workloads on small devices with limited resources. In particular, the lack of a garbage collector and the resulting predictable runtime makes it a great fit for running sensor data collectors. Creating such a loop together with the required driver to read data is what we cover in this chapter.

Chapter 10, Getting Practical with Rust, covers practical considerations in Rust programming, such as parsing command-line arguments, working with neural networks (machine learning with PyTorch's C++ API), searching, regular expressions, web requests, and much more.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime