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

make mime partial eq to use in pattern match #134

Open
dzmitry-lahoda opened this issue Feb 17, 2021 · 3 comments
Open

make mime partial eq to use in pattern match #134

dzmitry-lahoda opened this issue Feb 17, 2021 · 3 comments

Comments

@dzmitry-lahoda
Copy link

error: to use a constant of type `Mime` in a pattern, `Mime` must be annotated with `#[derive(PartialEq, Eq)]`
@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Feb 17, 2021

error: to use a constant of type `Mime` in a pattern, `Mime` must be annotated with `#[derive(PartialEq, Eq)]`
   --> libs\src\models.rs:345:13
    |
345 |             mime::APPLICATION_PDF => DownloadedFile::Pdf(file.content().to_owned()),

@kailan
Copy link

kailan commented Sep 13, 2021

This issue still stands and prevents pattern matching on constant types:

if let Some(mime::IMAGE_JPEG | mime::IMAGE_PNG) = beresp.get_content_type() {
    do_stuff();
}

The alternative to this code block following the pattern in the README would be:

if let Some(mime) = beresp.get_content_type() {
    match (mime.type_(), mime.subtype()) {
        (mime::IMAGE, mime::JPEG | mime::PNG) => do_stuff(),
        _ => {}
    }
}

@kailan
Copy link

kailan commented Sep 13, 2021

This would be resolved by #137.

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

2 participants