This is a fix for a compilation failure that surfaced recently, involving Palette 0.7.2–0.7.4, and Iced 0.12.0 and presumably later. It’s a breaking change, but hopefully with no or minimal impact. More about that below.
For those who aren’t familiar with it, Palette is a Rust library for working with colors, including color conversion and color management. Its features range from common tasks, like color blending or converting HSL to RGB, to more advanced topics. It leverages Rust’s type system, by encoding color space information as type parameters, to be able to prevent mistakes and to keep it open to extension and customization.
Error[E0275]: overflow evaluating the requirement &_: IntoIterator
This error, which seem to be a variant of rust-lang/rust#80542, was first reported by GitHub user Strosel. It originated from implementations of IntoIterator
for color types whose components can be iterated, such as Srgb<Vec<f32>>
, but the implementation could also imply that Srgb<Srgb<Srgb<...>>>
would be a possible candidate. This can pass type checking (for around nine months in this case) until the stars align and it suddenly traps the compiler in an infinite recursion. The “stars” in this case seemed to be having Iced 0.12.0 as a dependency, but it could have been anything else. It’s not a bug in Iced!
This type of error, or a very similar one, also occurred for arithmetic traits in 0.7.0. That was discovered almost immediately, so the problematic implementations were simply removed. The workaround this time is to limit the trait implementations to [T; N]
, &[T]
, &mut [T]
, Vec<T>
, and Box<[T]>
, to preserve the core functionality. This set could be expanded in the future, or a more generic implementation could return if/when the trait resolver can handle it.
The fix is released as a patch to reach out to current users, especially the many users of Iced, who may not have Palette as a direct dependency. If this change breaks your code in a way that’s not easy to work around, then please open an issue or discussion thread on GitHub.
Sorry for the trouble and thank you to those who helped reporting this and testing the fix.