rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
7.98k stars 363 forks source link

Strategy design pattern #120

Closed fade2black closed 3 years ago

fade2black commented 3 years ago

Working on https://medium.com/swlh/strategy-design-pattern-in-rust-5f5486cd294c?source=friends_link&sk=6871f4761dc6c4b7c0bc3ccefd22e408

NilSet commented 3 years ago

The blog post uses dynamic dispatch without any apparent need. The article in the book should probably cover the tradeoffs of using generics vs using dynamic dispatch.

fade2black commented 3 years ago

@NilSet How about removing it (dispatch version) completely?

fade2black commented 3 years ago

@NilSet Here I provide a version with static dispatch.

simonsan commented 3 years ago

Linked it to the PR, let's keep it open until we actually merge it. Maybe there is still some feedback from @pickfire and I'll also read through it the upcoming days. Cheers.