
- 180 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
About this book
Get familiar with writing programs in the trending new systems programming language that brings together the powerful performance of low-level languages with the advanced features like thread safety in multi-threaded code
Key Features
- Learn the semantics of Rust, which can be significantly different from other programming languages
- Understand clearly how to work with the Rust compiler which strictly enforces rules that may not be obvious
- Examples and insights beyond the Rust documentation
Book Description
Rust is an emerging programming language applicable to areas such as embedded programming, network programming, system programming, and web development. This book will take you from the basics of Rust to a point where your code compiles and does what you intend it to do!
This book starts with an introduction to Rust and how to get set for programming, including the rustup and cargo tools for managing a Rust installation and development workflow.
Then you'll learn about the fundamentals of structuring a Rust program, such as functions, mutability, data structures, implementing behavior for types, and many more. You will also learn about concepts that Rust handles differently from most other languages.
After understanding the Basics of Rust programming, you will learn about the core ideas, such as variable ownership, scope, lifetime, and borrowing. After these key ideas, you will explore making decisions in Rust based on data types by learning about match and if let expressions. After that, you'll work with different data types in Rust, and learn about memory management and smart pointers.
What you will learn
- Install Rust and write your first program with it
- Understand ownership in Rust
- Handle different data types
- Make decisions by pattern matching
- Use smart pointers
- Use generic types and type specialization
- Write code that works with many data types
- Tap into the standard library
Who this book is for
This book is for people who are new to Rust, either as their first programming language or coming to it from somewhere else. Familiarity with computer programming in any other language will be helpful in getting the best out of this book.
Tools to learn more effectively

Saving Books

Keyword Search

Annotating Text

Listen to it instead
Information
Basics of the Rust Language
- Functions, which are somewhat like miniature programs that are part of the larger program
- Modules, which are used to organize the program
- Expressions, which are how we tell the program to actually do specific things
- Branching, which is how we tell the program to make a decision
- Looping, which is how we tell the program to perform extended actions
- Structures, which is how we organize information for the program to process
- Attaching functions to structures or other data types, to make them more useful
Functions
Defining a function
- It must be made up of the following:
- English letters (the letters A through Z, in their lowercase or CAPITAL forms)
- Arabic numerals (the digits 0 through 9)
- Underscores(_)
- It can't start with a number (so 7samurai is not a valid name)
- If it starts with an underscore, it must have at least one further character (_ by itself has a special meaning)
fn main() {
println!("Hello, world!");
} Modules
Defining a module
A module as a section of a file
pub mod module_a {
pub fn a_thing() {
println!("This is a thing");
}
pub fn a_second_thing() {
a_thing();
println!("This is another thing");
}
} A module as a separate file
pub mod module_b;
pub fn a_thing() {
println!("This is a module_b thing");
}
pub fn a_second_thing() {
a_thing();
println!("This is another module_b thing");
} Accessing module contents from outside
Using the item's full name directly
Using the item's short name
Public and private module items
Table of contents
- Title Page
- Copyright and Credits
- About Packt
- Contributors
- Preface
- Getting Ready
- Basics of the Rust Language
- The Big Ideas – Ownership and Borrowing
- Making Decisions by Pattern Matching
- One Data Type Representing Multiple Kinds of Data
- Heap Memory and Smart Pointers
- Generic Types
- Important Standard Traits
- Other Books You May Enjoy
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app