Mastering Rust

Discover the powerful, hidden features of Rust you need to build robust, concurrent, and fast applications
Preview in Mapt

Mastering Rust

Vesa Kaihlavirta

9 customer reviews
Discover the powerful, hidden features of Rust you need to build robust, concurrent, and fast applications
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $39.99
Save 74%
Print + eBook
$49.99
RRP $49.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
$10.00
$49.99
$29.99 p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Mastering Rust Book Cover
Mastering Rust
$ 39.99
$ 10.00
Rust Essentials - Second Edition Book Cover
Rust Essentials - Second Edition
$ 35.99
$ 10.00
Buy 2 for $20.00
Save $55.98
Add to Cart

Book Details

ISBN 139781785885303
Paperback354 pages

Book Description

If concurrent programs are giving you sleepless nights, Rust is your go-to language. Being one of the first ever comprehensive books on Rust, it is filled with real-world examples and explanations, showing you how you can build scalable and reliable programs for your organization.

We’ll teach you intermediate to advanced level concepts that make Rust a great language. Improving performance, using generics, building macros, and working with threads are just some of the topics we’ll cover. We’ll talk about the official toolsets and ways to discover more. The book contains a mix of theory interspersed with hands-on tasks, so you acquire the skills as well as the knowledge. Since programming cannot be learned by just reading, we provide exercises (and solutions) to hammer the concepts in.

After reading this book, you will be able to implement Rust for your enterprise project, deploy the software, and will know the best practices of coding in Rust.

Table of Contents

Chapter 1: Getting Your Feet Wet
What is Rust and why should you care?
Installing Rust compiler and Cargo
A tour of the language and trying it out
Struct methods
Summary
Chapter 2: Using Cargo to Build Your First Program
Cargo and crates
Founding a project - cargo init
Dependencies, building, and running
Running tests - cargo test
Cargo.toml - project metadata
Editor integrations
Final exercise - starting our project
Summary
Chapter 3: Unit Testing and Benchmarking
Motivation and high-level view
Founding a city-builder game
Summary
Chapter 4: Types
String types
Arrays and slices
Generic types
Traits and implementations
Constants and statics
Summary
Chapter 5: Error Handling
Option and Result
Unwrapping
Mapping of the Option/Result values
Early returns and the try! macro
Panicking
Custom errors and the Error trait
Exercise
Summary
Chapter 6: Memory, Lifetimes, and Borrowing
LLVM
Function variables and the stack
The heap
Memory safety
Ownership
Lifetimes
The Drop trait
Collector types
Inspecting memory usage with std::mem
Final exercises
Summary
Chapter 7: Concurrency
Problems with concurrency
Closures
Threads
Sharing the Copy types
Channels
Locks and mutexes
Atomic Rc
The final exercise
Summary
Chapter 8: Macros
Introduction to metaprogramming
Dissecting println!
Debugging macros
Macro keywords
Repeating constructs
Example - an HTTP tester
Exercises
Summary
Chapter 9: Compiler Plugins
Basics of compiler plugins
Code generation as a workaround
Aster
Linter plugins
Macros 1.1 - custom derives
Exercises
Summary
Chapter 10: Unsafety and Interfacing with Other Languages
Unsafety
Calling C code from Rust
Connecting external libraries to Rust code
Creating Ruby extensions with Ruru
JavaScript/Node.js and Neon
Exercises
Summary
Chapter 11: Parsing and Serialization
Parsing fundamentals
Other parser libraries
Exercises
Summary
Chapter 12: Web Programming
Introduction to Rust and web programming
Hyper as a client
Hyper as a server
Rocket
Other web frameworks
Exercises
Summary
Chapter 13: Data Storage
SQLite
PostgreSQL
Connection pooling with r2d2
Diesel
Summary
Chapter 14: Debugging
Introduction to debugging
Exercises
Summary
Chapter 15: Solutions and Final Words
Chapter 1 - Getting Your Feet Wet
Chapter 2 - Using Cargo to Build Your First Program
Chapter 3 - Unit Testing and Benchmarking
Chapter 4 - Types
Chapter 5 - Error Handling
Chapter 6 - Memory, Lifetimes, and Borrowing
Chapter 7 - Concurrency
Chapter 8 - Macros
Chapter 9 - Compiler Plugins
Chapter 10 - Unsafety and Interfacing with Other Languages
Chapter 11 - Parsing and Serialization
Chapter 12 - Web Programming
Chapter 13 - Data Storage
Chapter 14 - Debugging

What You Will Learn

  • Implement unit testing patterns with the standard Rust tools
  • Get to know the different philosophies of error handling and how to use them wisely
  • Appreciate Rust's ability to solve memory allocation problems safely without garbage collection
  • Get to know how concurrency works in Rust and use concurrency primitives such as threads and message passing
  • Use syntax extensions and write your own
  • Create a Web application with Rocket
  • Use Diesel to build safe database abstractions

Authors

Table of Contents

Chapter 1: Getting Your Feet Wet
What is Rust and why should you care?
Installing Rust compiler and Cargo
A tour of the language and trying it out
Struct methods
Summary
Chapter 2: Using Cargo to Build Your First Program
Cargo and crates
Founding a project - cargo init
Dependencies, building, and running
Running tests - cargo test
Cargo.toml - project metadata
Editor integrations
Final exercise - starting our project
Summary
Chapter 3: Unit Testing and Benchmarking
Motivation and high-level view
Founding a city-builder game
Summary
Chapter 4: Types
String types
Arrays and slices
Generic types
Traits and implementations
Constants and statics
Summary
Chapter 5: Error Handling
Option and Result
Unwrapping
Mapping of the Option/Result values
Early returns and the try! macro
Panicking
Custom errors and the Error trait
Exercise
Summary
Chapter 6: Memory, Lifetimes, and Borrowing
LLVM
Function variables and the stack
The heap
Memory safety
Ownership
Lifetimes
The Drop trait
Collector types
Inspecting memory usage with std::mem
Final exercises
Summary
Chapter 7: Concurrency
Problems with concurrency
Closures
Threads
Sharing the Copy types
Channels
Locks and mutexes
Atomic Rc
The final exercise
Summary
Chapter 8: Macros
Introduction to metaprogramming
Dissecting println!
Debugging macros
Macro keywords
Repeating constructs
Example - an HTTP tester
Exercises
Summary
Chapter 9: Compiler Plugins
Basics of compiler plugins
Code generation as a workaround
Aster
Linter plugins
Macros 1.1 - custom derives
Exercises
Summary
Chapter 10: Unsafety and Interfacing with Other Languages
Unsafety
Calling C code from Rust
Connecting external libraries to Rust code
Creating Ruby extensions with Ruru
JavaScript/Node.js and Neon
Exercises
Summary
Chapter 11: Parsing and Serialization
Parsing fundamentals
Other parser libraries
Exercises
Summary
Chapter 12: Web Programming
Introduction to Rust and web programming
Hyper as a client
Hyper as a server
Rocket
Other web frameworks
Exercises
Summary
Chapter 13: Data Storage
SQLite
PostgreSQL
Connection pooling with r2d2
Diesel
Summary
Chapter 14: Debugging
Introduction to debugging
Exercises
Summary
Chapter 15: Solutions and Final Words
Chapter 1 - Getting Your Feet Wet
Chapter 2 - Using Cargo to Build Your First Program
Chapter 3 - Unit Testing and Benchmarking
Chapter 4 - Types
Chapter 5 - Error Handling
Chapter 6 - Memory, Lifetimes, and Borrowing
Chapter 7 - Concurrency
Chapter 8 - Macros
Chapter 9 - Compiler Plugins
Chapter 10 - Unsafety and Interfacing with Other Languages
Chapter 11 - Parsing and Serialization
Chapter 12 - Web Programming
Chapter 13 - Data Storage
Chapter 14 - Debugging

Book Details

ISBN 139781785885303
Paperback354 pages
Read More
From 9 reviews

Read More Reviews

Recommended for You

Rust Essentials - Second Edition Book Cover
Rust Essentials - Second Edition
$ 35.99
$ 10.00
Rust Programming By Example Book Cover
Rust Programming By Example
$ 35.99
$ 10.00
Rust Essentials - Second Edition Book Cover
Rust Essentials - Second Edition
$ 35.99
$ 10.00
Go Systems Programming Book Cover
Go Systems Programming
$ 39.99
$ 10.00
Modern C++ Programming Cookbook Book Cover
Modern C++ Programming Cookbook
$ 39.99
$ 10.00
Mastering Blockchain Book Cover
Mastering Blockchain
$ 39.99
$ 10.00