Crust of Rust: Dispatch and Fat Pointers

Crust of Rust: Dispatch and Fat Pointers

In this episode of Crust of Rust, we go over static and dynamic dispatch in Rust by diving deep into generics, monomorphization, and trait objects. As part of that, we also discuss what exactly the Sized trait is, what it's for, and how it interacts with Dynamically Sized traits.

In this episode of Crust of Rust, we go over static and dynamic dispatch in Rust by diving deep into generics, monomorphization, and trait objects. As part of that, we also discuss what exactly the Sized trait is, what it's for, and how it interacts with Dynamically Sized traits.

  • 0:00:00 Introduction
  • 0:03:08 Monomorphization
  • 0:16:13 (Static) Dispatch
  • 0:22:49 Trait Objects
  • 0:27:13 The Sized Trait
  • 0:39:34 Sizing Unsized Types
  • 0:46:47 Can I Recover The Concrete Type?
  • 0:47:56 Dynamic Dispatch
  • 0:53:08 Vtables
  • 1:02:13 Limitation: Multiple Traits
  • 1:08:32 Limitation: Associated Types
  • 1:10:30 Limitation: Static Trait Methods
  • 1:15:48 Disallowing Trait Objects
  • 1:20:58 Limitation: Generic Methods
  • 1:30:53 Limitation: No Non-Receiver Self
  • 1:33:00 Partial Object Safety
  • 1:39:54 Dropping Trait Objects
  • 1:43:03 Dynamically Sized Types
  • 1:48:30 Manual Vtables in std
  • 1:51:45 Q&A: Making Your Own DST
  • 1:53:41 Box([u8]) vs. Vec(u8)
  • 1:55:18 dyn Fn() vs. fn() vs. impl Fn()
  • 2:02:00 No Coherence This Stream
  • 2:03:00 Runtime Trait Detection
  • 2:04:41 Double-Dereferencing dyn Fn()
  • 2:06:55 Unsafe Vtable Comparions
  • 2:09:06 Slice of Trait Objects
  • 2:10:05 Codegen Units and Vtables
  • 2:10:55 The Any Trait

You can read more about Rust monomorphization in the Rust book at https://doc.rust-lang.org/book/ch10-01-syntax.html?highlight=performance#performance-of-code-using-generics. It also has some good discussion about Trait Objects (https://doc.rust-lang.org/book/ch17-02-trait-objects.html) and Dynamically Sized Types (https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait). For more details, the Rust reference also has more details on Trait Objects (https://doc.rust-lang.org/nightly/reference/types/trait-object.html) and Object Safety (https://doc.rust-lang.org/nightly/reference/items/traits.html#object-safety), and so does the Rustonomicon (https://doc.rust-lang.org/nomicon/exotic-sizes.html).

rust programming developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, ... by Oleg Sklyarov, Fullstack Developer at Skyeng company

Schedule the Program in Rust

In this Rust tutorial, we will discuss how we can schedule any Rust program by which it can execut. Rust is a multi-paradigm system programming language that can provide better memory safety while maintaining high performance. Rust also comes with a fairly nice build system (cargo) that keeps your libraries up to date or locks you to a specific version.

Tracking a Developer’s Journey From Documentation Visit

Measuring website activity provides only half the story. See how to best track the developer's journey and what funnel stages makes sense for API-first products

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.