1use serde::Serialize;
4
5#[derive(
6 Clone, Copy, Debug, strum::Display, Eq, Hash, strum::IntoStaticStr, PartialEq, Serialize,
7)]
8#[strum(const_into_str, serialize_all = "snake_case")]
9pub enum TypeKind {
10 Enum,
11 Struct,
12}
13
14impl TypeKind {
15 pub const fn label(self) -> &'static str {
16 self.into_str()
17 }
18}
19
20#[cfg(test)]
21mod tests {
22 use super::TypeKind;
23
24 #[test]
25 fn type_kind_labels_use_const_static_str_mapping() {
26 const ENUM_LABEL: &str = TypeKind::Enum.label();
27
28 assert_eq!(ENUM_LABEL, "enum");
29 assert_eq!(TypeKind::Struct.label(), "struct");
30 }
31}