Rust Programming
Duration 2 Full Days / 4 Half Days Modality Virtual / ILT
Platform Linux Level Introduction
Format Onsite and Virtual Audience Developers
Overview
Rust is a modern programming language with a unique set of
features, including memory safety, scalability, powerful
concurrency model, and zero-cost abstraction.
The combination of features, such ownership, lifetimes, and
trustworthy concurrency, included within Rust create strong
binaries that are reliable, robust, and highly performant.
Rust is a combination of various programming paradigms:
expression-oriented, pattern-oriented, and functional
programming models. This creates a development environment
that reenforces safe coding practices.
This course conveys the fundamentals of Rust including a
discussion of the features that make the language unique.
Graduate class with the ability to develop professional native
applications.
Finally, the class concludes with an introduction of threads.
Key Learning Areas
In this course you will learn the following:
Learn how to use the Rust tools, including Rustc and Cargo.
Learn the type system and variable declarations.
Learn the many unique aspects of the Rust language,
including ownership, lifetimes, and panics.
Learn about complex and aggregate types: arrays, vectors,
strings, tuples, and string.
Learn how to implement independent functions and methods
for structures.
Learn about traits, dynamic dispatch, and support of polymorphic
behavior.
Learn the basics of concurrent programming.
Prerequisite / Audience
The audience for this course is software engineers and developers.
Students should have six months of general programming experience.
Course outline
Introduction
Learn the general syntax of Rust. At the end of the first section, students
will have established a foundation in Rust. This includes learning the core
Rust tools, crate paradigm, and basic language syntax.
Course Introduction
Installing Rust
Hello World - Rust
Basic error handling
Transfer of control and methods
Cargo Package Manager
Rust CLI
Types and variables
Learn the type-safeness of the Rust language. This includes a full
complement of standard types, such as Integer, Float, Boolean, and String
types. A discussion of available mathematical and Boolean operators is
included. The various ways to declare variables and bindings in Rust are
presented.
Numbers on the Computer
Entry Points
Core Data Types
Operators
Scope and Shadowing
Declaring and using constants
Ownership and lifetimes
Learn specifics about two of the main unique features: ownership and
lifetimes. Professionals new to Rust often struggle with these concepts,
and also the borrow checker. This course presents these topics with a
clear and concise explanation, including benefits and contributions to safe
code.
Ownership
Borrow checker
References
Moving
Cloning
Lifetime
Lifetime elision
Transfer of control
Learn the standard transfer of control statements: if, for, while, and loop
statements. The match statement is presented with an introduction to
pattern matching.
If statement
While statement
For statement
Match statement
Short-circuiting
Complex types
Learn about the various sequences and complex types available in Rust.
This section begins with a discussion of arrays and vectors, which is a
dynamic sequence. This includes slices and partial sequences. Rust has a
variety of complex types.
Students will also learn how to use and implement with the Option <T> and
Result<T,E> types.
Structs
Enumeration
Option<t> If let while let
Arrays
Vectors
Slices
Strings
Tuples
HashMap
Pattern Matching
Generics
Functions and Methods
Learn how to modularize your programs with functions in Rust. Functions
are a primary component of almost every language. This module discusses
the essential elements of functions in Rust, including language syntax,
methods for structures, and associated functions. Closures are anonymous
methods but with a more diverse role in the language. Learn the various
places where a closure can be used.
Functions
Methods
Closures
Structures
Pattern oriented programming
Pattern-oriented programming (POP) in Rust is a programming approach
that focuses on identifying and abstracting patterns in code to make it more
modular, reusable, and maintainable. In Rust, patterns can be used to
represent complex data structures and control flow structures, enabling
developers to write more expressive and concise code.
Match and patterns
Decomposition
Nested decomposition
Option type
Result type
Traits
Learn how to define and implement traits. Traits are similar to an interface
in other languages. This includes creating extensible solutions using
polymorphism with dynamic dispatch. Benefits of traits, such as abstraction,
are also reviewed.
Define traits
Implementation
Abstraction
Dynamic Dispatch
Polymorphism
Important traits
Concurrency
Learn the basics of concurrent programming. This includes how to create
threads using independent functions and closures. Channels, the central
artifact of concurrent programming in Rust, is also introduced.
Starting a thread
Thread handles
Closures
Channels
Setup Instructions
Here are the setup instructions for the Rust programming class. The
instructor will use a combination of Visual Studio code for the Rust IDE and
the Rust CLI during class. Students can choose any Rust IDE, and are not
required to use Visual Studio code.
Rust language
For participating in class and class examples, install the Rust Programming
Language.
https://www.rust-lang.org/tools/install
After installing Rust, run these commands from a CLI (command line
interface).
Rustc --version
Cargo –version
If not successful, confirm that these tools are included in the path
environment variable.
Here are websites that provide additional assistance when installing Rust
on Linux, MacOS, or Windows.
Linux
https://tek.io/2DDO1Gd
https://bit.ly/3lTTUAx
MacOS / Linux
https://bit.ly/3lTTUAx
MacOS
https://bit.ly/2GE1DT8
Windows
https://bit.ly/3jUaBd3
Rust Playground
The Rust Playground is an online sandbox for using the Rust Programming
Language.
You can practice with the stable, beta, or nightly builds. In addition, you
can run both debug and release (optimized) builds.
Here is the link to the Rust Playground:
https://play.rust-lang.org/
Visual Studio Code (VS Code)
Here is the installation page for deploying VS Code to various
environments.
https://code.visualstudio.com/docs/setup/setup-overview
After installation of the VS Code application, start it.
From the left panel, install the Rust for Visual Studio Code extension.
If extensions are not visible, select Extensions from the View menu.
You can also select the Extension icon from the vertical toolbar.
After installing, make sure the extension is activated, not disabled.
You are ready to begin developing code using the Rust Language!