fix: trait for profile feature type from str

This commit is contained in:
Gabriele Musco 2024-08-27 23:11:51 +02:00
commit 828343b8ea

View file

@ -88,16 +88,19 @@ pub enum ProfileFeatureType {
} }
impl ProfileFeatureType { impl ProfileFeatureType {
pub fn from_string(s: String) -> Self { pub fn iter() -> Iter<'static, ProfileFeatureType> {
match s.trim().to_lowercase().as_str() { [Self::Libsurvive, Self::Basalt].iter()
"libsurvive" => Self::Libsurvive,
"basalt" => Self::Basalt,
_ => panic!("Unknown profile feature type"),
} }
} }
pub fn iter() -> Iter<'static, ProfileFeatureType> { impl From<&str> for ProfileFeatureType {
[Self::Libsurvive, Self::Basalt].iter() fn from(s: &str) -> Self {
match s.trim().to_lowercase().as_str() {
"libsurvive" => Self::Libsurvive,
"basalt" => Self::Basalt,
"openhmd" => Self::OpenHmd,
_ => panic!("Unknown profile feature type"),
}
} }
} }