The Visitor Pattern Showdown – A 70x Faster Alternative? | Advanced Rust Part 9

The Visitor Pattern Showdown – A 70x Faster Alternative? | Advanced Rust Part 9

5.036 Lượt nghe
The Visitor Pattern Showdown – A 70x Faster Alternative? | Advanced Rust Part 9
The Visitor is an often employed pattern to flexibly add functionality to a type hierarchy. But it comes at the price of low performance due to its use of dynamic dispatch. Today, we explore a performant, easy to implement, and very Rust-idiomatic alternative to the visitor pattern. We make comparisons, discuss trade-offs and find some best-practice rules. This video is part of a playlist: https://www.youtube.com/playlist?list=PLFdNoRgzggbr7tkQsO4VrF1UGy0ji9sZl GitHub Visitor Pattern: https://github.com/Thodin/visitor_pattern GitHub Pattern Matching: https://github.com/Thodin/pattern_matching 00:00 Intro 00:55 Visitor Pattern Recap 03:42 Why do we need the Visitor? 06:14 Pattern Matching Implementation 07:59 Rust's Enums 08:58 Commonalities 09:23 Differences 10:17 Performance Comparison 13:46 When to choose which 16:56 Outro #rustlang #softwarearchitecture #softwaredevelopment