Rust Cookbook

75-80 recipes for learning Rust programming
Preview in Mapt

Rust Cookbook

Vigneshwer Dhinakaran

5 customer reviews
75-80 recipes for learning Rust programming
Mapt Subscription
FREE
$29.99/m after trial
eBook
$25.20
RRP $35.99
Save 29%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$25.20
$44.99
$29.99 p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Rust Cookbook Book Cover
Rust Cookbook
$ 35.99
$ 25.20
Mastering Rust Book Cover
Mastering Rust
$ 39.99
$ 28.00
Buy 2 for $35.00
Save $40.98
Add to Cart

Book Details

ISBN 139781785880254
Paperback320 pages

Book Description

If you are building concurrent applications, server-side programs, or high-performance applications, you will benefit from this language. This book comes with a lot of application-specific recipes to kick-start your development of real-world high-performance applications with the Rust programming language and integrating Rust units into your existing applications. In this book, you will find some 80 practical recipes written in Rust that will allow you to use the code samples right away in your existing applications. These recipes have been tested with stable rust compiler versions of 1.14.0 and above.

This book will help you understand the core concepts of the Rust language, enabling you to develop efficient and high-performance applications by incorporating features such as zero cost abstraction and better memory management.

We’ll delve into advanced-level concepts such as error handling, macros, crates, and parallelism in Rust. Toward the end of the book, you will learn how to create HTTP servers and web services, building a strong foundational knowledge in server-side programming and enabling you to deliver solutions to build high-performance and safer production-level web applications and services using Rust.

Table of Contents

Chapter 1: Let us Make System Programming Great Again
Introduction
Setting up Rust in Linux and macOS
Setting up Rust in Windows
Creating your first Rust program
Defining a variable assignment
Setting up Boolean and the character types
Controlling decimal points, number formats, and named arguments
Performing arithmetic operations
Defining mutable variables
Declaring and performing string operations
Declaring arrays and using slices in Rust
Declaring vectors in Rust
Declaring tuples in Rust
Performing calculations on two numbers
Chapter 2: Advanced Programming with Rust
Introduction
Defining an expression
Defining constants
Performing variable bindings
Performing type casting in Rust
Decision-making with Rust
Looping operations in Rust
Defining the enum type
Defining closures
Performing pointer operations in Rust
Defining your first user-defined data type
Adding functionality to the user-defined data type
Similar functionality for different data type
Chapter 3: Deep Diving into Cargo
Introduction
Creating a new project using Cargo
Downloading an external crate from crates.io
Working on existing Cargo projects
Running tests with Cargo
Configuration management of the project
Building the project on the Travis CI
Uploading to crates.io
Chapter 4: Creating Crates and Modules
Introduction
Defining a module in Rust
Building a nested module
Creating a module with struct
Controlling modules
Accessing modules
Creating a file hierarchy
Building libraries in Rust
Calling external crates
Chapter 5: Deep Dive into Parallelism
Introduction
Creating a thread in Rust
Spawning multiple threads
Holding threads in a vector
Sharing data between threads using channels
Implementing safe mutable access
Creating child processes
Waiting for a child process
Making sequential code parallel
Chapter 6: Efficient Error Handling
Introduction
Implementing panic
Implementing Option
Creating map combinator
Creating and_then combinator
Creating map for the Result type
Implementing aliases
Handling multiple errors
Implementing early returns
Implementing the try! macro
Defining your own error types
Implementing the boxing of errors
Chapter 7: Hacking Macros
Introduction
Building macros in Rust
Implementing matching in macros
Playing with common Rust macros
Implementing designators
Overloading macros
Implementing repeat
Implementing DRY
Chapter 8: Integrating Rust with Other Languages
Introduction
Calling C operations from Rust
Calling Rust commands from C
Calling Rust operations from Node.js apps
Calling Rust operations from Python
Writing a Python module in Rust
Chapter 9: Web Development with Rust
Introduction
Setting up a web server
Creating endpoints
Handling JSONRequests
Building custom error handlers
Hosting templates
Chapter 10: Advanced Web Development in Rust
Introduction
Setting up the API
Saving user data in MongoDB
Fetching user data
Deleting user data
Chapter 11: Advanced Rust Tools and Libraries
Introduction
Setting up rustup
Setting up rustfmt
Setting up rust-clippy
Setting up and testing with Servo
Generating random numbers
Writing lines to a file
Parsing unstructured JSON
Parsing URL from a string
Decompressing a tarball
Compressing a directory to a tarball
Finding file extensions recursively

What You Will Learn

  • Understand system programming language problems and see how Rust provides unique solutions
  • Get to know the core concepts of Rust to develop fast and safe applications
  • Explore the possibility of integrating Rust units into existing applications to make them more efficient
  • Achieve better parallelism, security, and performance
  • Explore ways to package your Rust application and ship it for deployment in a production environment
  • Discover how to build web applications and services using Rust to provide high-performance to the end user

Authors

Table of Contents

Chapter 1: Let us Make System Programming Great Again
Introduction
Setting up Rust in Linux and macOS
Setting up Rust in Windows
Creating your first Rust program
Defining a variable assignment
Setting up Boolean and the character types
Controlling decimal points, number formats, and named arguments
Performing arithmetic operations
Defining mutable variables
Declaring and performing string operations
Declaring arrays and using slices in Rust
Declaring vectors in Rust
Declaring tuples in Rust
Performing calculations on two numbers
Chapter 2: Advanced Programming with Rust
Introduction
Defining an expression
Defining constants
Performing variable bindings
Performing type casting in Rust
Decision-making with Rust
Looping operations in Rust
Defining the enum type
Defining closures
Performing pointer operations in Rust
Defining your first user-defined data type
Adding functionality to the user-defined data type
Similar functionality for different data type
Chapter 3: Deep Diving into Cargo
Introduction
Creating a new project using Cargo
Downloading an external crate from crates.io
Working on existing Cargo projects
Running tests with Cargo
Configuration management of the project
Building the project on the Travis CI
Uploading to crates.io
Chapter 4: Creating Crates and Modules
Introduction
Defining a module in Rust
Building a nested module
Creating a module with struct
Controlling modules
Accessing modules
Creating a file hierarchy
Building libraries in Rust
Calling external crates
Chapter 5: Deep Dive into Parallelism
Introduction
Creating a thread in Rust
Spawning multiple threads
Holding threads in a vector
Sharing data between threads using channels
Implementing safe mutable access
Creating child processes
Waiting for a child process
Making sequential code parallel
Chapter 6: Efficient Error Handling
Introduction
Implementing panic
Implementing Option
Creating map combinator
Creating and_then combinator
Creating map for the Result type
Implementing aliases
Handling multiple errors
Implementing early returns
Implementing the try! macro
Defining your own error types
Implementing the boxing of errors
Chapter 7: Hacking Macros
Introduction
Building macros in Rust
Implementing matching in macros
Playing with common Rust macros
Implementing designators
Overloading macros
Implementing repeat
Implementing DRY
Chapter 8: Integrating Rust with Other Languages
Introduction
Calling C operations from Rust
Calling Rust commands from C
Calling Rust operations from Node.js apps
Calling Rust operations from Python
Writing a Python module in Rust
Chapter 9: Web Development with Rust
Introduction
Setting up a web server
Creating endpoints
Handling JSONRequests
Building custom error handlers
Hosting templates
Chapter 10: Advanced Web Development in Rust
Introduction
Setting up the API
Saving user data in MongoDB
Fetching user data
Deleting user data
Chapter 11: Advanced Rust Tools and Libraries
Introduction
Setting up rustup
Setting up rustfmt
Setting up rust-clippy
Setting up and testing with Servo
Generating random numbers
Writing lines to a file
Parsing unstructured JSON
Parsing URL from a string
Decompressing a tarball
Compressing a directory to a tarball
Finding file extensions recursively

Book Details

ISBN 139781785880254
Paperback320 pages
Read More
From 5 reviews

Read More Reviews

Recommended for You

Mastering Rust Book Cover
Mastering Rust
$ 39.99
$ 28.00
Rust Essentials - Second Edition Book Cover
Rust Essentials - Second Edition
$ 35.99
$ 25.20
Rust Programming By Example Book Cover
Rust Programming By Example
$ 35.99
$ 25.20
Learning Rust Book Cover
Learning Rust
$ 35.99
$ 25.20
Modern C++ Programming Cookbook Book Cover
Modern C++ Programming Cookbook
$ 39.99
$ 28.00
Network Programming with Rust Book Cover
Network Programming with Rust
$ 35.99
$ 25.20