Remove blanket From<&str> impl for Hsla
Since this is a fallible operation we don't want to have a blanket infallible conversion from any arbitrary `&str` to an `Hsla`.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user