O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building Reusable Code with Rust

Video Description

Use generics, traits, and macros to write clean and reusable Rust libraries that are easy to understand and maintain

About This Video

  • Know the concepts of macros and compiler plugins and how they help with more complex projects
  • Use Rust's standard library to build a reusable and easy-to-understand API
  • Hands-on example of how to package your Rust code into reusable crates and publish them on crates.io

In Detail

Rust is the ideal language for writing safe, correct code in a way that won't make you pull your hair out. This course will teach you how to build reusable Rust code so that you can stop copying and pasting 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.

The code bundle for this video course is available at - https://github.com/PacktPublishing/Building-Reusable-Code-with-Rust

Table of Contents

  1. Chapter 1 : Basics of Code Reuse
    1. The Course Overview 00:03:16
    2. Setting Up the Rust Development Environment 00:03:54
    3. Exploring Code Reuse in Rust 00:03:15
    4. Loops and Iterators 00:05:40
    5. Using Functional Programming Loops 00:13:49
    6. Functions in Rust 00:03:06
  2. Chapter 2 : Using Generics in Rust
    1. Exploring Generics 00:02:27
    2. Use Generic Functions to Reuse Algorithms 00:03:49
    3. Reuse Structures in Enums and Structs 00:02:31
    4. Working with Generic in Struct Methods 00:03:43
    5. Generics in the Rust Standard Library – Part I 00:03:45
    6. Generics in the Rust Standard Library – Part II 00:05:48
  3. Chapter 3 : Defining Interfaces with Traits
    1. Exploring Traits 00:03:12
    2. Using Trait Bounds and Trait Objects to Communicate Interfaces 00:03:42
    3. Associated Types versus Generics and Trait Inheritance 00:02:57
    4. Exploring Traits, Generics, and Performance 00:03:30
    5. Traits in the Rust Standard Library – Part I 00:07:43
    6. Traits in the Rust Standard Library – Part II 00:06:25
  4. Chapter 4 : Hacking the Language with Macros and Compiler Plugins
    1. Write Code with Code – Metaprogramming in Rust 00:02:29
    2. Use Declarative Macros to Write Less Code 00:04:05
    3. Using Procedural Macros for Custom Derive 00:04:44
    4. Macros in the Rust Standard Library – Part I 00:04:55
    5. Macros in the Rust Standard Library – Part II 00:05:40
  5. Chapter 5 : Reusing the Code with Other People Using Modules and Crates
    1. Introducing Crates 00:05:06
    2. Using Modules to Define the Structure of Crates 00:04:27
    3. Using a Crate with Cargo.toml 00:06:06
    4. Publishing to crates.io 00:02:47