Make `gen_constants_and_matches!` macro logical

This commit imporves the overall 'look' of the macro and makes it appear
more logical
next
Sayan Nandan 3 years ago
parent 58830edc80
commit 2eedb041bb

@ -36,7 +36,7 @@ use std::vec::IntoIter;
pub type ActionIter = IntoIter<String>; pub type ActionIter = IntoIter<String>;
macro_rules! gen_constants_and_matches { macro_rules! gen_constants_and_matches {
($con:ident, $buf:ident, $db:ident, $($action:ident),*; $($fns:expr),*) => { ($con:ident, $buf:ident, $db:ident, $($action:ident => $fns:expr),*) => {
mod tags { mod tags {
//! This module is a collection of tags/strings used for evaluating queries //! This module is a collection of tags/strings used for evaluating queries
//! and responses //! and responses
@ -75,26 +75,25 @@ where
}; };
let mut buf = buf.into_iter(); let mut buf = buf.into_iter();
gen_constants_and_matches!( gen_constants_and_matches!(
con, buf, db, GET, SET, UPDATE, DEL, HEYA, EXISTS, MSET, MGET, MUPDATE, SSET, SDEL, con, buf, db,
SUPDATE, DBSIZE, FLUSHDB, USET, KEYLEN, MKSNAP, LSKEYS; GET => actions::get::get,
actions::get::get, SET => actions::set::set,
actions::set::set, UPDATE => actions::update::update,
actions::update::update, DEL => actions::del::del,
actions::del::del, HEYA => actions::heya::heya,
actions::heya::heya, EXISTS => actions::exists::exists,
actions::exists::exists, MSET => actions::mset::mset,
actions::mset::mset, MGET => actions::mget::mget,
actions::mget::mget, MUPDATE => actions::mupdate::mupdate,
actions::mupdate::mupdate, SSET => actions::strong::sset,
actions::strong::sset, SDEL => actions::strong::sdel,
actions::strong::sdel, SUPDATE => actions::strong::supdate,
actions::strong::supdate, DBSIZE => actions::dbsize::dbsize,
actions::dbsize::dbsize, FLUSHDB => actions::flushdb::flushdb,
actions::flushdb::flushdb, USET => actions::uset::uset,
actions::uset::uset, KEYLEN => actions::keylen::keylen,
actions::keylen::keylen, MKSNAP => admin::mksnap::mksnap,
admin::mksnap::mksnap, LSKEYS => actions::lskeys::lskeys
actions::lskeys::lskeys
); );
Ok(()) Ok(())
} }

Loading…
Cancel
Save