#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub enum Kind {
Dependency,
Crate,
Native,
Framework,
All,
}
impl Kind {
pub const DEPENDENCY: &'static str = "dependency";
pub const CRATE: &'static str = "crate";
pub const NATIVE: &'static str = "native";
pub const FRAMEWORK: &'static str = "framework";
pub const ALL: &'static str = "all";
}
impl From<Kind> for &'static str {
fn from(kind: Kind) -> Self {
match kind {
Kind::Dependency => Kind::DEPENDENCY,
Kind::Crate => Kind::CRATE,
Kind::Native => Kind::NATIVE,
Kind::Framework => Kind::FRAMEWORK,
Kind::All => Kind::ALL,
}
}
}
impl From<Kind> for String {
fn from(kind: Kind) -> Self {
let kind: &str = kind.into();
kind.into()
}
}
#[cfg(test)]
mod tests {
use super::Kind;
#[test]
fn test_into_string() {
let kind: String = Kind::Dependency.into();
assert_eq!(kind, Kind::DEPENDENCY);
let kind: String = Kind::Crate.into();
assert_eq!(kind, Kind::CRATE);
let kind: String = Kind::Native.into();
assert_eq!(kind, Kind::NATIVE);
let kind: String = Kind::Framework.into();
assert_eq!(kind, Kind::FRAMEWORK);
let kind: String = Kind::All.into();
assert_eq!(kind, Kind::ALL);
}
}