🎨 Passes action keys by reference in dispatch

This commit is contained in:
Manuel Cillero 2024-07-27 23:05:41 +02:00
parent b481d84cba
commit 5f9c1e4b15
9 changed files with 41 additions and 31 deletions

View file

@ -19,12 +19,12 @@ pub fn add_action(action: ActionBox) {
}
}
pub fn dispatch_actions<A, B, F>(key: ActionKey, f: F)
pub fn dispatch_actions<A, B, F>(key: &ActionKey, f: F)
where
A: ActionTrait,
F: FnMut(&A) -> B,
{
if let Some(list) = ACTIONS.read().unwrap().get(&key) {
list.iter_map(f)
if let Some(list) = ACTIONS.read().unwrap().get(key) {
list.iter_map(f);
}
}