pub type HWType = u16; <% rows.each do |row| %> pub const <%= row.desc %>: HWType = <%= row.value %>; // <%= row.ref %> <% end %> pub fn to_str(a: HWType) -> Result<&'static str, ()> { match a { <% rows.each do |row| %> <%= row.value %> => Ok("<%= row.desc %>"), <% end %> _ => Err(()), } }