Shortening function calls with closures I wrote this code that makes a fairly long function call multiple times using some of the same parameters

match key {
    Key { code: KeyCode::Left, .. } =&gt; self.map.move_object_by(PLAYER, -1, 0),
    Key { code: KeyCode::Right, .. } =&gt; self.map.move_object_by(PLAYER, 1, 0),
    Key { code: KeyCode::Up, .. } =&gt; self.map.move_object_by(PLAYER, 0, -1),
    Key { code: KeyCode::Down, .. } =&gt; self.map.move_object_by(PLAYER, 0, 1),
}


I was looking for a way to shortened this function call with something simlar to C/C++ macros. I looked into Rust Macros but they are clearly very different. The solution I came up with is creating a function pointer to a closure that calls the function self.map.move_object_by

let mut move_player = |x, y| self.map.move_object_by(PLAYER, x, y);

match key {
    Key { code: KeyCode::Left, .. } =&gt; move_player(-1, 0),
    Key { code: KeyCode::Right, .. } =&gt; move_player(1, 0),
    Key { code: KeyCode::Up, .. } =&gt; move_player(0, -1),
    Key { code: KeyCode::Down, .. } =&gt; move_player(0, 1),
}


Is this bad? Will this cause any real slow downs or bugs? Are there other/better ways of doing this?
The Rust compiler will probably inline the code, and generate the exact same code in both situations. So there isn't a performance issue.

However, I think there is a better way to write it:

if let Some((x,y)) = match key.code {
   KeyCode::Left =&gt; Some((-1, 0)),
   KeyCode::Right =&gt; Some((1, 0)),
   KeyCode::Up =&gt; Some((0, -1)),
   KeyCode::Down =&gt; Some((0, 1)),
   _ =&gt; None
} {
   self.map.move_object_by(PLAYER, x, y);
}