I create a macro in rust:
macro_rules! generate_i64_get_inc{
($($field_name:ident),*) => {
$(
pub(super) fn get_$field_name(&self) -> i64 {
self. $field_name.load(Ordering::Acquire)
}
pub(super) fn inc_$field_name(&mut self, value: i64) -> i64 {
self. $field_name.fetch_add(value, Ordering::AcqRel) + value
}
)*
};
}
and invoke it:
impl TxStats {
generate_i64_get_inc!(pg_alloc, pg_count);
}
but get error on get_$field_name
:
expected one of
(
or<
, foundpg_alloc
I hope it works well.