mime
mime copied to clipboard
make mime partial eq to use in pattern match
error: to use a constant of type `Mime` in a pattern, `Mime` must be annotated with `#[derive(PartialEq, Eq)]`
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()),
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(),
_ => {}
}
}
This would be resolved by #137.