Closed ripytide closed 2 weeks ago
I ran into this error briefly with the following bit of code:
type Component<I> = <<I as GenericImageView>::Pixel as Pixel>::Component;
/// Convert the supplied image to grayscale. Alpha channel is discarded.
pub fn grayscale<I: GenericImageView>(
image: &I,
) -> ImageBuffer<Luma<Component<I>>, Vec<Component<I>>> {
grayscale_with_type(image)
}
│rustc: the associated type `<<I as image::GenericImageView>::Pixel as rgb::ComponentMap>::Component` may not live long enough │
│the associated type `<<I as image::GenericImageView>::Pixel as rgb::ComponentMap>::Component` must be valid for the static lifetime..
I'm not that comfortable working with 'static
bounds yet so I'll close this until I've done a bit more playing around and isolating of a smaller minimal working example.
I'm afraid it could have a fallout for generic code.
There's static on the outer type that prevents accidental references. But this could infect function return types, other containers.