We may earn an affiliate commission when you visit our partners.
Packt Publishing

Rust is a systems programming language with a focus on safety, especially safe concurrency, supporting both functional and imperative paradigms, syntactically similar to C++, but its designers intend it to provide better memory safety while still maintaining performance. With this hands-on, practical course, you’ll begin from scratch by getting familiar with the basic syntax and concepts of Rust, defining functions and creating variables & much more. Then you'll learn to test your code by building a simple crate with a tested, usable, well-documented API using Cargo & RustDoc. Next, you will work with different forms of code reuse, loops, map, filter and fold to save time and resources & to use your code in a reusable manner in your apps.

Read more

Rust is a systems programming language with a focus on safety, especially safe concurrency, supporting both functional and imperative paradigms, syntactically similar to C++, but its designers intend it to provide better memory safety while still maintaining performance. With this hands-on, practical course, you’ll begin from scratch by getting familiar with the basic syntax and concepts of Rust, defining functions and creating variables & much more. Then you'll learn to test your code by building a simple crate with a tested, usable, well-documented API using Cargo & RustDoc. Next, you will work with different forms of code reuse, loops, map, filter and fold to save time and resources & to use your code in a reusable manner in your apps.

By end of this course you will be able to avoid code duplication and write clean reusable code, also you'll be comfortable building various solutions in Rust

Contents and Overview

This training program includes 2 complete courses, carefully chosen to give you the most comprehensive training possible.

The first course, Learning Rust begins by getting familiar with the basic syntax and concepts of Rust, from writing a Hello World program to defining functions and creating variables. Then you’ll see how to manage toolchains with Rust up and build your first command-line program. Moving on, you’ll explore Rust’s type system to write better code and put it into practice in a simple markup language. You’ll learn to use Rust’s functional programming features to perform a physics simulation and use the Rayon crate to parallelize your computations. Finally, you’ll discover the best practices and test your code by building a simple crate with a tested, usable, well-documented API using Cargo and RustDoc. By the end of the video, you’ll be comfortable building various solutions in Rust. You’ll be able to take advantage of Rust’s powerful type system and a rich ecosystem of libraries, or “crates”, available through the Cargo package manager.

The second course, Building Reusable Code with Rust will start with teaching you how to build reusable Rust code so that you can stop copying and pasting the code. Write code that can adapt to many different usages. You will reuse code by using advanced features such as traits, generics, and macros. You will work with different forms of code reuse, loops, map, filter and fold to save time and resources. Achieve higher-level reuse without sacrificing runtime performance. Organize your code into modules and crates to publish them to crates .io. By the end of the course, you will be able to avoid code duplication and write clean reusable code.

Enroll now

What's inside

Learning objective

This course is aimed at developers, c/c++, rust & system developers who are familiar with programming and want to learn how to code in rust and re-use rust code and libraries from scratch.

Syllabus

Learning Rust

This video gives an overview of the entire course.

In this video, we will examine the basic syntax of Rust and see its variables called “bindings” at work.

  • Learn that bindings are immutable by default

  • Learn that Rust supports mutable bindings

  • Know that the compiler will prevent us from using a variable that was not initialized

Read more

In this video, we will examine the built-in types provided by Rust.

  • Load up the Rust playground

  • Learn about the two types of Rust – strong and dynamic

  • Get acquainted with the built-in types and check on some programming as well

In this video, we will see how rust code is organized, see some more types, and build some more programs.

  • Learn some basics about crates and modules

  • Learn that there are a number of imports that come into a program, known as “preludes”

In this video, we will talk about the functionality that is available by default on every Rust program: Rust standard library.

  • Get to know about the contents of the rust standard library

  • Learn a bit about the Rust standard library’s philosophy

In this video, we will build a simple Fibonacci calculator.

  • Define the program to be written

  • Sketch out the implementation types

  • Build a working implementation

In this video, we will build a more efficient Fibonacci program.

  • Define the performance bottleneck of the previous program

  • Understand how dynamic programming will help

  • Implement a dynamic solution

In this video, we will cover installing and managing Rust with Rustup.

  • Learn about multiple release channels in Rust

  • Learn to install Rust on your system

  • Learn that Rustup makes it easier to manage the versions of other software

In this video, we will learn how to manage our tools with Rustup.

  • Learn the basic commands used in Rustup

  • Learn to set an override for a project

  • Discuss tradeoffs between stable, beta and nightly

In this video, we will talk about creating projects with Cargo.

  • Create a new project on our respective terminal

  • Create a main application file that runs all our codes and brings them all together

In this video, we talk about the crate ecosystem around rust.

  • Get to know about crates.io, a public crates repository

  • Learn about semantic versioning

We talk about the Rust documentation ecosystem.

  • Learn the URL for projecting information on any particular crate

  • Explore and learn more about the doc

In this video, we will be adding dependencies with Cargo.

  • Use Cargo to build the project

In this video, we will check out the importance of the borrow checker.

  • Discuss memory corruption problems

  • Explain how memory corruption problems are bad

  • Explain how the borrow checker prevents memory unsafety

In this video, we will talk about ownership, borrowing, and RAII.

  • Find out what ownership, borrowing and RAII is all about

In this video, we will take a look at shared and exclusive access and see how they work with the Rust compiler.

  • Create a program

  • Learn how to use shared and exclusive access

In this video, we will talk about the phenomenon of fighting with the borrow checker.

  • Learn what exactly fighting with the borrow checker means

  • Learn the different designs in a borrow checker

  • Learn why we must not fight the borrow checker

In this video, we will learn about strings, strs, vecs, and slices.

  • Learn about strings and vecs

  • Learn about strs and slices

In this video, we will understand and deal with borrow checker errors.

  • Understand what the borrow checker is

  • Get to know the types of borrow checker errors

In this video, we will talk about structured data, also known as structs or data structures

  • Create a simple program using struct and get the output

  • Explore the different ways in which we can use structs in our programs

In this video, we will examine another basic kind of type in rust called enumerations or enum.

  • Create a simple program using enum and get the output

  • Explore the different ways in which we can use enum in our programs

In this video, we talk about match expressions.

  • Create a program on the simulation of guiding a robot around using enumerations

  • Learn to write commands for the robot using enums

  • Learn to use the match expression in writing a program efficiently to control the robot

In this video, we will see how to design a simple markup language.

  • Create a simple program on finite-state machines

  • Explore what goes into designing the markup language

In this video, we implement the markup language.

  • Explore the previous program by making a few alterations

  • Learn to use the derivation keyword to copy and clone the values in the enum state

  • Explore the usage of several match expressions within the program

In this video, we will be taking a look at traits.

  • Learn the specific behavior of traits

  • Understand the default methods used in traits

  • Explore the syntax and parameters used in traits

In this video, we will discuss some of the built-in traits that come with the rust compiler and standard library.

  • Learn about comparison

  • Learn about display and debug

  • Learn about clone and copy and also about the iterator

In this video, we will learn how to write our own traits.

  • Understand the various applications of traits

  • Create a simple program

  • Learn how to use traits within the program

In this video, we will learn about generic functions.

  • Learn about arguments for generic functions

  • Learn the generic syntax and trait bounds

  • Explore the concepts through a programming example

In this video, we will learn about generic types.

  • Learn about arguments for generic types

  • Learn about generic type syntax

  • Learn about existing generic types

In this video, we will learn about traits, objects, and dynamic dispatch.

  • Learn about static dispatch

  • Learn about dynamic dispatch

In this video, we will learn about closures in Rust.

  • Learn what are closures and their syntax

  • Understand closure syntax

  • Learn various other concepts such as closing variables, closure return strategies, and so on

In this video, we will take a look at iterators.

  • Define iterators

  • Create iterators

  • Learn about the different methods used

In this video, we will learn map, filter, and fold.

  • Learn about map, filter, and fold

  • Learn about the combination of the three

  • Understand the perks of using them

In this video, we will learn about the Barycenter finder.

  • Create a program

  • Compute the gravitational center of the system – Barycenter

In this video, we will take a look at how to parallelize the Barycenter finder.

  • Parallelize the existing Barycenter program

  • Understand rayon and itertools

In this video, we will take a look at breaking up code with modules.

  • Understand why it is important to break up code

  • Learn the basic organization

  • Understand that it is important to document the code

In this video, we will discuss error handling.

  • Learn about the two error handling types

  • Propagate the errors upwards

In this video, we will take a look at API designs.

  • Use naming conventions

  • Learn about interoperability, document, and flexibility

In this video, we will learn about unit testing.

  • Create a new rust library called Bucketizer

  • Understand that working on unit tests helps to iterate new designs without any application code

In this video, we will learn about integration testing.

  • Implement the Bucketizer

  • Create a well-designed crate

In this video, we will talk about documentation.

  • Discuss documentation in the Bucketizer project

  • Get a brief recap of the course

Test Your Knowledge
Building Reusable Code with Rust

This video provides an overview of the entire course.

How can we try the code examples from the course? By setting up the Rust development environment.

  • Understand the options available: playground and rustup

  • Learn to test simple code using the online playground

  • Learn to install the toolchain locally with rustup

A brief overview of the code reuse mechanisms in Rust, which we'll discuss further in the course.

  • Understand the considerations of code reusability

  • Learn what Rust provides us for code reuse

How do we avoid repetitive code using loops and properly use iterators?

  • See why for loops only accept iterators

  • Learn what the IntoIterator trait has to do with the for loop

  • Understand the ways to get different iterators with or without reference

The aim of this video is to learn an alternative way of doing loops.

  • Learn iterator adaptor and consuming adaptor

  • Know when we should use functional programming loops as against for loops

  • See how lazy evaluation can help you do more than a for loop

How we can use one of the most common features in programming languages—functions—to avoid duplication?

  • Understand the basic syntax of functions

  • See how functions take typed parameters

  • Learn the common mistake of moving ownership into a function

How and where can generics help us to reuse code in Rust?

  • Learn how generics can help us reuse high-level algorithms

  • Learn how generics can help us reuse high-level data structures

  • Understand where generics can be applied

How can we reuse an algorithm for different types? Generic functions can help us abstract away the types in a function signature.

  • Understand the basic syntax of generics in functions

  • Know why not all types can fit into all generic functions

  • See how we can use a trait bound to restrict the types used in a generic function

How to reuse common data structures for different types? With generic on structs and enums.

  • Learn how generic struct can abstract away the types

  • Learn how multiple generic types can be used in one struct

  • Understand how the same concept can be applied to enums

The aim of this video is to learn how struct methods can use generic just like normal functions.

  • Learn the basic syntax of generic on struct methods

  • Understand why we need impl<T> instead of just impl

  • See how we can implement a generic struct method for only certain types

Show how generics are used in the Rust standard library.

  • See how option<T> uses generic to represent optional values

  • See how result<T> uses generic to represent a success/fail result

  • Know how to use option and result in error handling

The aim of this video is to showcase how generics are used in the Rust standard library.

  • See how collections like vector or hash use generics

  • Learn how smart pointers and wrappers use generics

  • See how we can compose wrappers using the generic syntax

The aim of this video is to learn the basic syntax of trait and trait bound.

  • Learn the basic syntax of trait

  • See how trait can help us define interfaces

  • Learn how trait bound can help us enforce interfaces

How can we enforce and use a trait without knowing the solid type? Trait bounds and trait objects can help us here.

  • See how trait bounds are used in a real-world example

  • Learn the "where" form of trait bound syntax

  • See how a trait object can be used instead of a solid type

Using generics on traits may cause us to accidentally create multiple implementations. Associated type can guarantee that it's only implemented once.

  • Understand why generics on traits may cause multiple implementations

  • See how associated type solves this problem

  • Learn how trait inheritance can enforce more complex trait relationships

Traits and generics have different effects on performance. Learn the difference between static dispatch and dynamic dispatch.

  • Learn about static dispatch and the code bloat problem

  • Learn about dynamic dispatch and its performance impact

  • See how a trait object is implemented internally

How do we do operator overloading and type conversion in Rust? The Rust standard library uses traits for this.

  • See how operator overloading can be achieved by traits

  • Learn how lifetime and function calls also utilize traits

  • Understand how From and Into traits help us do type conversion

How to tell the compiler that our custom type has a special property? Marker traits will help. We also talk about some useful std traits.

  • Learn about marker traits and how they interact with the compiler

  • Know how to define custom formatting with Display and Debug

  • Learn how a default trait can be useful in defining defaults

Learn what metaprogramming is and the tools available in Rust.

  • Learn what metaprogramming is

  • Understand the options for metaprogramming in Rust

  • Know when to use metaprogramming

Some code repetition is not possible to eliminate by the language itself. We can use declarative macros to abstract away that.

  • Understand the syntax for defining declarative macros

  • See a real-world example of vec!()

  • Learn about the namespace for macro and why we need macro_use

Implementing repetitive traits is cumbersome. Using procedural macros, we can create custom derive rules to reduce clutter.

  • Learn how custom derive works

  • Learn how we organize the folder structure for custom derive code

  • Understand how we use proc_macro, syn, and quote to achieve the custom derive logic

The aim of this video is to walk through important macros in the Rust standard library.

  • Briefly review what we’ve learned about derive

  • Walk through macros for formatting

  • Walk through macros for introspection, including files, and more

The aim of this video is to walk through important macros in the Rust standard library.

  • Walk through macros for conditional compiling

  • Walk through macros for error handling

  • Walk through macros that aid development like unimplemented, panic, or assert

How do we create a self-contained unit of module that can be reused? Using Cargo to create crates.

  • Learn how the "cargo new" command creates crates

  • Learn how a binary crate is structured

  • Learn how a library crate is structured

How do we create namespace in crates to convey the structure of our code? Modules are built exactly for that.

  • See how module definition works in one file

  • Learn how we can split modules into files and folders

  • Understand how the "pub" keyword controls the accessibility of modules

How do we reuse the modules we created or other people created? We can specify the dependency in Cargo.toml.

  • Learn how Cargo.toml works

  • How to use third-party or local crates

  • How to include the crate in the code with "extern crate" and "use"

How do we publish our crate to the world? We need to put them on crates.io.

  • Understand what crates.io is

  • Understand the requirement for your crate to be published

  • Demonstrate the procedure of publishing to crates.io

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Covers Rust's memory safety features, which are intended to provide better memory management than C++, while maintaining performance, making it valuable for systems programming
Explores Rust's type system, which allows developers to write better code and take advantage of a rich ecosystem of libraries, or 'crates,' available through the Cargo package manager
Teaches how to use traits, generics, and macros to write code that can adapt to many different usages, which is useful for avoiding code duplication and writing clean, reusable code
Includes a section on installing and managing Rust with Rustup, which makes it easier to manage the versions of other software and to work with multiple release channels in Rust
Examines the borrow checker, which prevents memory unsafety, and discusses ownership, borrowing, and RAII, which are core concepts in Rust for managing memory
Requires setting up the Rust development environment, which may involve installing the toolchain locally with rustup, but this is standard for Rust development

Save this course

Save Rust: Building Reusable Code with Rust from Scratch to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Rust: Building Reusable Code with Rust from Scratch with these activities:
Review C++ Concepts
Strengthen your understanding of C++ fundamentals, as Rust shares syntactical similarities. This will ease your transition into Rust's unique features.
Browse courses on C++
Show steps
  • Review basic syntax and data structures in C++.
  • Practice writing simple programs in C++.
Read 'The Rust Programming Language'
Gain a solid foundation in Rust by reading the official book. Understand core concepts and syntax before diving into reusable code.
Show steps
  • Read the first few chapters covering basic syntax and ownership.
  • Experiment with the code examples provided in the book.
Implement Data Structures in Rust
Reinforce your understanding of Rust's ownership and borrowing system by implementing common data structures. This will help you write safe and efficient code.
Browse courses on Data Structures
Show steps
  • Implement a linked list, stack, and queue in Rust.
  • Write unit tests to ensure the data structures are working correctly.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Write a Blog Post on Rust Traits
Solidify your understanding of Rust traits by explaining them in a blog post. Teaching others is a great way to learn.
Browse courses on Traits
Show steps
  • Research and understand the different types of traits in Rust.
  • Write a clear and concise blog post explaining traits with examples.
  • Publish the blog post on a platform like Medium or your own website.
Build a Simple CLI Tool
Apply your knowledge of Rust to build a practical CLI tool. This will give you hands-on experience with the language and its ecosystem.
Browse courses on CLI
Show steps
  • Choose a simple CLI tool to build, such as a to-do list manager or a file converter.
  • Use Cargo to create a new Rust project.
  • Implement the CLI tool using Rust's standard library and any necessary crates.
  • Write unit tests and integration tests to ensure the tool is working correctly.
Read 'Programming Rust'
Expand your knowledge of Rust with a comprehensive guide. Explore advanced topics and real-world examples to deepen your understanding.
Show steps
  • Read chapters on advanced topics like concurrency and macros.
  • Try the examples and exercises provided in the book.
Contribute to a Rust Crate
Deepen your understanding of Rust by contributing to an open-source crate. This will expose you to real-world code and best practices.
Show steps
  • Find a Rust crate on crates.io that you are interested in contributing to.
  • Read the crate's documentation and code to understand its functionality.
  • Identify a bug or feature that you can contribute to.
  • Submit a pull request with your changes.

Career center

Learners who complete Rust: Building Reusable Code with Rust from Scratch will develop knowledge and skills that may be useful to these careers:
Systems Programmer
A Systems Programmer works on the core components of operating systems, device drivers, and other low-level software. This role requires a deep understanding of memory management, concurrency, and performance optimization, all of which are addressed in this course as it teaches Rust, a language that provides better memory safety while maintaining performance. This course helps build a foundation in the kind of systems programming that directly impacts performance and efficiency through the use of Rust and also provides practical experience in building tested, well-documented, reusable code, which is vital for systems programming.
Robotics Software Engineer
Robotics Software Engineers develop software for robots, focusing on real-time control, sensor integration, and motion planning. This requires a solid understanding of concurrency, performance, and low-level programming. This course may be useful because it teaches Rust, a language known for its efficiency and safety. With the knowledge gained from this course, the Robotics Software Engineer can develop software that interacts with hardware components and manages real time data. The course's focus on code reuse helps manage the complexity of robot software.
Firmware Engineer
Firmware Engineers develop low-level software that controls hardware devices. They require strong skills in embedded programming, real-time systems, and hardware interaction. Although this course does not directly address hardware interaction, it may be helpful because it teaches Rust, a language well suited for resource-constrained environments. A Firmware Engineer wanting to build maintainable, safe, high performance components would benefit greatly from this course. The focus on code reuse is very important in managing firmware complexity.
Embedded Systems Engineer
Embedded Systems Engineers design and develop software for systems with specific functions, such as those in automobiles and medical devices. They require a strong understanding of low-level programming, resource constraints, and real-time processing. This course may be useful because it explores Rust, a language designed for safety and performance, which is very relevant to resource-constrained environments. Through building reusable code with Rust, an Embedded Systems Engineer can apply what they learn about writing efficient and robust software to their hardware-specific projects.
Operating Systems Developer
An Operating Systems Developer is involved with the core software that manages computer hardware and resources. A deep understanding of system-level programming, memory management, and concurrency control is needed. This course may prove to be useful since it teaches the Rust programming language. Rust is particularly relevant for its focus on memory safety and performance. This course also helps the Operating Systems Developer by providing practical experience with toolchains, documentation, and building well-structured reusable modules which are important in managing large scale OS projects.
High-Performance Computing Engineer
High Performance Computing Engineers design software and systems for supercomputers and clusters. They need expertise in parallel computing, distributed systems, and performance optimization. This course may be useful for those looking to get into High Performance Computing because it covers Rust, which enables concurrent programming. The course also covers testing and documentation, which can help the High Performance Computing Engineer build stable parallel programs. The emphasis on reusable code is also helpful when building complex parallel systems.
Game Developer
Game Developers create the software that powers video games, focusing on performance, graphics, and user experience. A deep understanding of memory management, concurrency, and optimization is essential. This course may be helpful because it teaches Rust, a language known for its safety and speed. Game developers can learn to write high-performance code by building reusable game specific components. The course’s emphasis on code reuse also fits well with the development of different game systems.
Quantitative Analyst
Quantitative Analysts develop mathematical and statistical models for financial markets. They often need to write high performance code for simulations, algorithmic trading, and risk management. This course may be helpful as it teaches Rust, which is known for its high performance and safety, especially in concurrent environments. Since the course focuses on writing reusable code, the Quantitative Analyst can use it to develop libraries of functions that are critical for financial models.
Software Engineer
Software Engineers design, develop, and maintain software applications. While the title is broad, this course may be useful for those focused on building high-performance and reliable applications, as the course teaches Rust. Rust's memory safety and concurrency features, emphasized in this course, help in building robust applications. Moreover, the training in writing reusable code using Rust can lead to more efficient software design and development workflows for a Software Engineer.
Compiler Engineer
A Compiler Engineer works on the software that translates programming languages into machine code. This role involves deep knowledge of language semantics, optimization techniques, and compiler design principles. This course may be useful as it introduces the learner to Rust, a systems programming language whose compiler enforces safe practices. By using Rust, a Compiler Engineer can learn more about the practical aspects of high performance language design. The course's focus on code reuse can also help in organizing compiler components.
Research Scientist
Research Scientists in computer science often work on novel algorithms, systems, and programming languages. This role typically requires an advanced degree such as a Master's or Phd. This course may be useful as it introduces them to the Rust programming language, which has advanced features. By combining theoretical knowledge with practical implementation in Rust, a Research Scientist can use the course to build prototypes for their research. The emphasis on code reuse and documentation will aid them in the development of these projects.
Blockchain Developer
Blockchain Developer is a role that focuses on the design and implementation of distributed ledger systems. They must have a solid grasp of cryptography, data structures, and concurrency. This course may be helpful because it teaches Rust, a language that is increasingly used due to its security and concurrency features. Those intending to enter this field can take this course to build reusable components and libraries. The emphasis on documentation in the course is also helpful in this context.
Software Architect
Software Architects design the high-level structure of software systems, focusing on scalability, maintainability, and performance. This role needs a broad understanding of programming paradigms, design patterns, and technology choices. This course may be useful as it provides a deep dive into Rust, which allows for the creation of high-performance components needed in modern software systems. Additionally, the course provides practical approaches to code organization, documentation, and reusability which are key skills for a Software Architect.
Database Engineer
Database Engineers are crucial to the design, development, and maintenance of database systems. This role requires a deep understanding of data structures, concurrency, and performance optimization. Though this course may not directly cover database systems, it may still be helpful since the course teaches Rust, a systems level language known for its memory safety and performance, which is critical in database systems. A Database Engineer will find the course helpful in learning how to structure large software systems with reusable components.
DevOps Engineer
DevOps Engineers are responsible for automating and streamlining software development processes, including building, testing, and deployment. This role requires a broad range of skills including the ability to work within different tool chains and build systems. They also need to understand memory safety and performance issues, which are introduced in this course. This course may be useful as it teaches how to create and manage crates, which are reusable packages, within the Rust ecosystem. This contributes to the DevOps Engineer's ability to build and automate software delivery pipelines.

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Rust: Building Reusable Code with Rust from Scratch.
Is the official guide to Rust and provides a comprehensive overview of the language. It covers everything from basic syntax to advanced topics like ownership, borrowing, and concurrency. It valuable resource for both beginners and experienced programmers looking to learn Rust. This book is commonly used as a textbook at academic institutions.
Provides a practical and comprehensive guide to Rust programming. It covers a wide range of topics, including ownership, borrowing, concurrency, and macros. It valuable resource for experienced programmers looking to learn Rust. This book adds more depth to the existing course by providing real-world examples and case studies.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser