Function design_pattern_examples_rust::strategy::strategy_exercise
source · pub fn strategy_exercise() -> Result<(), String>
Expand description
Example of using the “Strategy” design pattern.
The Strategy pattern provides a way to easily assign different algorithms to an object instance that can be changed at the time the object is created.
In this exercise, the StrategyShowEntries instance sorts and displays a list of EntryInformation elements. Three different sorting strategies are provided (Name, Age, Height) and an option to reverse the normal order of the sort.