Rust Programming for C++ Developers
Course Description
Aimed at C++ developers, this five-day Rust programming course is
designed to help you transition from C++ to Rust with confidence. Led by an expert
trainer, the course combines engaging content with hands-on labs, ensuring you grasp
Rust's unique features and gain practical experience. By the end of the course, you'll be confident in writing comprehensive tests and documentation, making you an effective Rust programmer.
5 Days
Contact us for pricing
Objectives
Participants will learn how to:Master Rust Syntax and Semantics: Get comfortable writing and understanding Rust code, including how to use control flow, functions, and module imports.
Implement Memory Management: Learn to manage memory effectively in Rust by mastering concepts like ownership, borrowing, and lifetimes to ensure your code is both safe and efficient.
Leverage Cargo and Crates: Become adept at using Cargo to manage Rust projects and dependencies, and explore how to integrate popular crates like Serde, Tokio, and SQLx to add powerful features to your applications.
Utilize Rust's Concurrency Model: Discover how to write efficient and concurrent programs using Rust's concurrency tools, such as threads, Mutex, RwLock, and async/await.
Employ Pattern Matching and Generics: Understand and apply pattern matching with enums and functions, and use generics to create flexible and reusable code.
Create and Test Rust Applications: Develop complete Rust applications, including writing tests with Rust's testing framework and generating clear, comprehensive documentation using Rustdoc.
Pre-requisites
Proficiency in C++ Programming: A strong understanding of C++ syntax, functions, and modulesBasic Knowledge of Programming Concepts: Familiarity with variables, expressions, control flow (loops and conditionals), and basic data structures.
Experience with Version Control Systems: Basic experience using Git for version control, including committing, branching, and merging code.
Understanding of Software Development Practices: Familiarity with project management tools and practices - virtual environments, dependency management, and code testing.
Who should attend
This course is designed for C++ developers looking to expand their programming skills with Rust. It is ideal for software engineers, system programmers, and developers interested in performance-critical and concurrent applications. Whether in a new or existing role, this course provides the knowledge and skills to excel in Rust programming.Getting Started with Rust
What is Rust?Philosophy and Goals
History and Motivation
Rust Community and Ecosystem
Exploring the Rust Playground
Rust Editors
Setting up VSCode with Rust ExtensionsUsing Rust Rover IDE
Debugging Rust Code in VSCode
Integrating GitHub Copilot for Rust
Hello World
Creating a New Rust ProjectWriting the Main Function
Printing to the Console
Adding Comments to Code
Cargo
What is Cargo?Run Command
Build Command
Build Release Command
Install Third-Party Crates
Scalar Types and Data
Comparing Rust Types with Python TypesDefining Constants in Rust
Using Immutable Variables
Utilizing Mutable Variables
Code Logic
Writing If StatementsUsing Loops with Break
Implementing While Loops
Functions
Defining and Calling FunctionsSpecifying Parameter and Return Types
Creating and Using Closure Functions
Modules
Importing Modules from the Standard LibraryImporting Modules from Third-Party Crates
Defining Custom Modules
Importing and Using Custom Modules
Built-In Macros
print! and println!format!
assert!, assert_eq!, and assert_ne!
vec!
include_str! and include_bytes!
Memory Management
Problems with Manual ManagementProblems with Garbage Collection
Ownership & Borrowing
References
Lifetimes
Strings and String Slices
What is a String and a String Slice?String Slices
String Objects
Convert Between Slices and Strings
Print Strings with Interpolation
Tuples
Understanding What a Tuple IsUsing Heterogeneous Elements
Accessing and Destructuring Tuple Elements
Immutability of Tuples
Enums
Defining and Using EnumsExploring Enum Variants and Methods
Pattern Matching with Enums
Working with Result and Option Enums
Structs
What is a Struct?Create Instance
Field Init Shorthand
Struct Methods
Constructor Pattern
Vectors
Creating and Managing VectorsAdding and Removing Elements
Accessing and Iterating Over Elements
Slicing, Checking Length, and Capacity
Collections and Iterators
What is a Vector?Create a Vector
Add and Remove Elements
Access Elements
Iterate over Elements
Traits
Defining and Implementing TraitsUsing Default Trait Implementations
Passing Traits as Parameters and Return Types
Generics
Defining and Implementing Generics in RustUsing Generic Bounds and Multiple Types
Writing Where Clauses for Generics
Pattern Matching
What is Pattern Matching?Match Statement
If Let Statement
While Let Statement
Pattern Matching with Enums
Concurrent Programming
Introduction to Concurrent Programming ConceptsUsing Multiple Threads in Rust
Working with Mutex, RwLock, and Arc
Message Passing with Channels
Futures and Async/Await for Concurrency
Unsafe Rust
Understanding the Need for Unsafe RustWorking with Raw Pointers and Dereferencing
Calling Unsafe Functions and Creating Safe Abstractions
Using Unsafe Traits and Blocks
Macros and Metaprogramming
Defining and Using Macros with macro_rules!Pattern Matching in Macros
Defining and Expanding Custom Macros
Tests
Writing and Organizing Test Functions
Using Test Attributes and Coverage Tools
Assertions with assert!, assert_eq!, and assert_ne!
Tests
What is a Test?Test Functions
Test Organization
Test Attributes
Test Coverage
Memory-Safe Programming
How Memory is Managed on a ComputerHow the Operating System Views Memory
How Memory is Allocated in a Process
Pitfalls with manual memory management
Rust's Approach to Safe Memory Management
Memory Management
Variables and their DataVariable Addresses and Data Addresses
Mutability of Variables and their Data
Variable and Data Ownership
Rust's Approach to Variables and their Data
Rust Memory Model
Ownership and BorrowingReferences and Mutability
Stack Allocation vs Heap Allocation
Smart Pointers
Thread Safety through Atomics and Locks
Smart Pointers
What are Smart Pointers?When to use Smart Pointers?
Unknown Size at Compile Time
Self-Referential Structures
Interior Mutability
Smart Pointer Types
BoxRc, Weak, and Arc
Cell and RefCell
RwLock and Mutex
C++ and Rust Interoperability
Challenges and ConcernsCalling Rust from C++
Calling C++ from Rus
Valgrind and Rust
Documentation with Rustdoc
Generating Documentation with RustdocAdding Triple-Slash Comments and #[doc] Attributes
Linking and Cross-Referencing Documentation
RustRust ProgrammingC++OOPCargoSerdeTokioSQLxMutexRwLock