Skip to main content

strategy_pattern_fn

Attribute Macro strategy_pattern_fn 

Source
#[strategy_pattern_fn]
Expand description

Attribute macro to register a function as part of a strategy pattern.

This macro should be applied to functions that will be executed dynamically based on a key.

§Parameters

  • strategy: The name of the struct that represents the strategy.
  • key: A string used to identify the function within the strategy.

§Example

#[strategy_pattern_fn(strategy = GreetingStrategy, key = "formal_greeting")]
pub fn formal_greeting(name: String) -> String {
    format!("Good day, {name}")
}