Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

associated type Alpha must be specified #17

Open
Sjord opened this issue Jun 20, 2020 · 1 comment
Open

associated type Alpha must be specified #17

Sjord opened this issue Jun 20, 2020 · 1 comment

Comments

@Sjord
Copy link

Sjord commented Jun 20, 2020

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?

@Sjord
Copy link
Author

Sjord commented Jun 24, 2020

@vaidehijoshi ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant