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

add static bound to Pixel::Component to match HetPixel #134

Closed
wants to merge 1 commit into from

Conversation

ripytide
Copy link
Contributor

No description provided.

@kornelski
Copy link
Owner

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.

@ripytide
Copy link
Contributor Author

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.

@ripytide ripytide closed this Aug 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants