use super::*;
impl SpaceKind {
#[must_use]
pub fn from_serialized(serialized: &str) -> Self {
match serialized {
"function" => Self::Function,
"class" => Self::Class,
"struct" => Self::Struct,
"trait" => Self::Trait,
"impl" => Self::Impl,
"unit" => Self::Unit,
"namespace" => Self::Namespace,
"interface" => Self::Interface,
_ => Self::Unknown,
}
}
}
impl fmt::Display for SpaceKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match self {
SpaceKind::Unknown => "unknown",
SpaceKind::Function => "function",
SpaceKind::Class => "class",
SpaceKind::Struct => "struct",
SpaceKind::Trait => "trait",
SpaceKind::Impl => "impl",
SpaceKind::Unit => "unit",
SpaceKind::Namespace => "namespace",
SpaceKind::Interface => "interface",
};
write!(f, "{s}")
}
}