Get the latest tech news

Exploring Dynamic Dispatch in Rust


Let me preface this by saying that I am a novice in the world of rust (though I'm liking things so far!), so if I make technical...

According to that documentation, the memory layout of a Mammal trait object made from a Cat will consist of two pointers arranged like: It incurs a cost when 'constructing' a trait object, unlike the C++ approach in which a cast to a base pointer is free (or just some addition for multiple inheritance). Because rust does not (yet) support struct inheritance, the problem of determining the correct subobject to pass as self, does not exist.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of Dynamic Dispatch

Dynamic Dispatch

Related news:

News photo

Gatehouse – a composable, async-friendly authorization policy framework in Rust

News photo

Crabtime: Zig’s Comptime in Rust

News photo

Chibi: PNG-tuber application made in Rust