When using css-colors, I would like to create a function that takes any color, whether it is RGB or HSL:
fn darken(c: Color) {
c.darken(percent(10))
}
However, this doesn't work, because the trait Color has an Alpha type, which is not specified in this case. The compiler gives an error:
error[E0191]: the value of the associated type `Alpha` (from the trait `css_colors::Color`) must be specified
--> src/main.rs:12:14
|
12 | fn darken(c: Color) {
| ^^^^^ associated type `Alpha` must be specified
Is there any way around this? Should there be two traits, one for any color and one for colors that can be converted to alpha?
When using css-colors, I would like to create a function that takes any color, whether it is RGB or HSL:
However, this doesn't work, because the trait Color has an Alpha type, which is not specified in this case. The compiler gives an error:
Is there any way around this? Should there be two traits, one for any color and one for colors that can be converted to alpha?