From 828343b8ea98f53dec392d80e076b18172617893 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Tue, 27 Aug 2024 23:11:51 +0200 Subject: [PATCH] fix: trait for profile feature type from str --- src/profile.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/profile.rs b/src/profile.rs index 255ec84..6fe83b2 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -88,17 +88,20 @@ pub enum ProfileFeatureType { } impl ProfileFeatureType { - pub fn from_string(s: String) -> Self { + pub fn iter() -> Iter<'static, ProfileFeatureType> { + [Self::Libsurvive, Self::Basalt].iter() + } +} + +impl From<&str> for ProfileFeatureType { + 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"), } } - - pub fn iter() -> Iter<'static, ProfileFeatureType> { - [Self::Libsurvive, Self::Basalt].iter() - } } impl Display for ProfileFeatureType {