use crate::field_witnesses::{FieldName, HasField};
#[macro_export]
macro_rules! DeclarativeFieldWitnesses {
($struct_name:ident, $($field_name:ident: $field_type:ty),* $(,)?) => {
$(
#[doc = concat!("Field witness for the `", stringify!($field_name), "` field of `", stringify!($struct_name), "`")]
#[derive(Debug, Clone)]
pub struct $field_name;
// Implement FieldName for each field marker
impl $crate::field_witnesses::FieldName for $field_name {
fn field_name() -> &'static str {
stringify!($field_name)
}
}
impl $crate::field_witnesses::HasField<$field_name> for $struct_name {
type Output = $field_type;
fn get_field(&self) -> &Self::Output {
&self.$field_name
}
}
)*
};
}