1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use ;
use TokenStream;
/// Attribute macro to define a strategy type.
///
/// This macro should be applied to a struct that will serve as a strategy container.
/// It allows defining a type that will store function pointers and execute them dynamically.
///
/// # Parameters
/// - `search`: Defines the search mode for function keys. It can be:
/// - `"Exact"` → Exact match.
/// - `"IgnoreCase"` → Case-insensitive match.
/// - `"RegExp"` → Uses regular expressions.
///
/// # Example
/// ```
/// #[strategy_pattern_type(search = "IgnoreCase")]
/// pub struct GreetingStrategy(fn(String) -> String);
/// ```
/// 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}")
/// }
/// ```