Skip to content

Instantly share code, notes, and snippets.

@a10y
Created September 19, 2024 20:07
Show Gist options
  • Save a10y/1a4c0b90428566e7f929e0d8f56d58e1 to your computer and use it in GitHub Desktop.
Save a10y/1a4c0b90428566e7f929e0d8f56d58e1 to your computer and use it in GitHub Desktop.
macro_rules! make_encoding_ids_rec {
($count:expr) => {};
($count:expr, $encoding:ident $($tts:tt)*) => {
pub const $encoding: u16 = $count;
make_encoding_ids_rec!(($count+1u16) $($tts)*);
}
}
macro_rules! make_encoding_ids {
($($encodings:ident),*) => {
make_encoding_ids_rec!(1u16 $(, $encodings)*);
};
}
make_encoding_ids! {
FIRST
, SECOND
, THIRD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment