#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq)]
pub enum DataType {
#[default]
Serial,
Struct,
Numeric,
String,
}
impl core::fmt::Display for DataType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(match self {
Self::Serial => "serial",
Self::Struct => "struct",
Self::Numeric => "numeric",
Self::String => "string",
})
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn names_follow_the_reference() {
let names = [
DataType::Serial,
DataType::Struct,
DataType::Numeric,
DataType::String,
]
.map(|ty| alloc::string::ToString::to_string(&ty));
assert_eq!(names, ["serial", "struct", "numeric", "string"]);
}
}