Remove blanket `From<&str>` impl for `Hsla`

Marshall Bowers created

Since this is a fallible operation we don't want to have a blanket
infallible conversion from any arbitrary `&str` to an `Hsla`.

Change summary

crates/gpui2/src/color.rs           |  6 ------
crates/theme2/src/default_colors.rs | 18 +++++++++---------
2 files changed, 9 insertions(+), 15 deletions(-)

Detailed changes

crates/gpui2/src/color.rs 🔗

@@ -233,12 +233,6 @@ impl Hsla {
     }
 }
 
-impl From<&str> for Hsla {
-    fn from(s: &str) -> Self {
-        Rgba::try_from(s).unwrap().into()
-    }
-}
-
 // impl From<Hsla> for Rgba {
 //     fn from(value: Hsla) -> Self {
 //         let h = value.h;

crates/theme2/src/default_colors.rs 🔗

@@ -4,6 +4,7 @@ use crate::{
     colors::{GitStatusColors, PlayerColor, PlayerColors, StatusColors, SystemColors, ThemeColors},
     scale::{ColorScaleSet, ColorScales},
     syntax::SyntaxTheme,
+    ColorScaleStep,
 };
 
 fn neutral() -> DefaultColorScaleSet {
@@ -291,22 +292,21 @@ struct DefaultColorScaleSet {
     dark_alpha: [&'static str; 12],
 }
 
-// See [ColorScaleSet] for why we use index-1.
 impl DefaultColorScaleSet {
-    pub fn light(&self, index: usize) -> Hsla {
-        self.light[index - 1].into()
+    pub fn light(&self, index: ColorScaleStep) -> Hsla {
+        Rgba::try_from(self.light[index - 1]).unwrap().into()
     }
 
-    pub fn light_alpha(&self, index: usize) -> Hsla {
-        self.light_alpha[index - 1].into()
+    pub fn light_alpha(&self, index: ColorScaleStep) -> Hsla {
+        Rgba::try_from(self.light_alpha[index - 1]).unwrap().into()
     }
 
-    pub fn dark(&self, index: usize) -> Hsla {
-        self.dark[index - 1].into()
+    pub fn dark(&self, index: ColorScaleStep) -> Hsla {
+        Rgba::try_from(self.dark[index - 1]).unwrap().into()
     }
 
-    pub fn dark_alpha(&self, index: usize) -> Hsla {
-        self.dark_alpha[index - 1].into()
+    pub fn dark_alpha(&self, index: ColorScaleStep) -> Hsla {
+        Rgba::try_from(self.dark_alpha[index - 1]).unwrap().into()
     }
 }