Prefer .remove() over .get() to avoid clone

This commit is contained in:
ConnorSkees 2020-02-17 09:08:28 -05:00
parent 33d486ccde
commit af443f8f57

View File

@ -9,10 +9,10 @@ macro_rules! arg {
}; };
}; };
($args:ident, $idx:literal, $name:literal=$default:expr) => { ($args:ident, $idx:literal, $name:literal=$default:expr) => {
match $args.get(stringify!($idx)) { match $args.remove(stringify!($idx)) {
Some(v) => v.clone(), Some(v) => v.eval(),
None => match $args.get($name) { None => match $args.remove($name) {
Some(v) => v.clone(), Some(v) => v.eval(),
None => $default, None => $default,
}, },
}; };