-
Notifications
You must be signed in to change notification settings - Fork 19
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
Struct parameterized with colorspace newtype not accepted by compiler #13
Comments
Rust has "orphan rules" which guarantee that globally for every possible program, there can't be more than one implementation of any trait for any type. Simplifying, you can implement a trait for a type only if either:
You can't implement someone else's trait (like However, I may be able to add a more general Add implementation. I'll check that. |
I've released v0.8.9 which allows Note that |
Thank you for the prompt turnaround! The rules make sense, I have no problem using map_rgb/new_alpha, and this should be what I need! |
This issue looks to have been resolved in |
Hi,
I'm working with texture generation using this crate and would like to have the pixel operations use saturating_* math functions instead of the default.
Per the docs, I implemented a colorspace newtype and a different "add" implementation for it. However, the compiler insists I must provide Add for the parametrized type itself (
rgb::RGBA<openktg::LinearLight, u16>
): which I can't do as this is an external crate.I am relatively new to Rust, so is this something I'm missing, or a legitimate bug with parameterized RGB structs?
Here's a minimal gist to illustrate: https://gist.github.com/rust-play/40a8fc9422f88c5af8bcd5900fe9230a
The text was updated successfully, but these errors were encountered: