clippy: replace deref() with &*, remove into_iter

This commit is contained in:
Lynne Megido 2021-11-25 08:45:20 +10:00
parent 65a560d5f4
commit b6c2d75bdb
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 5 additions and 7 deletions

View file

@ -6,7 +6,6 @@
use std::collections::{BTreeSet, HashMap}; use std::collections::{BTreeSet, HashMap};
use std::fs::File; use std::fs::File;
use std::io::{self, Read, Seek, SeekFrom}; use std::io::{self, Read, Seek, SeekFrom};
use std::ops::Deref;
use std::path::Path; use std::path::Path;
use std::str::FromStr; use std::str::FromStr;
@ -284,11 +283,11 @@ pub fn mime_type<T: MimeDb>(db: &T, path: &Path) -> io::Result<Option<Mime>> {
// another is ZIP - many file formats (DOCX, ODT, JAR...) are just ZIP files with particular data structures. // another is ZIP - many file formats (DOCX, ODT, JAR...) are just ZIP files with particular data structures.
// determining that a file is in one of the MS office formats in particular requires looking quite far into the // determining that a file is in one of the MS office formats in particular requires looking quite far into the
// file. // file.
&& mime != APPLICATION_ZIP.deref() && mime != &*APPLICATION_ZIP
// doc/ppt/xls files are a subset of what's known as an "OLE2 compound document storage", at least according to // doc/ppt/xls files are a subset of what's known as an "OLE2 compound document storage", at least according to
// shared-mime-info. if a pre-OOXML era MS office file is scanned and identified as x-ole-storage, reading further // shared-mime-info. if a pre-OOXML era MS office file is scanned and identified as x-ole-storage, reading further
// will allow it to be detected correctly as the appropriate filetype. // will allow it to be detected correctly as the appropriate filetype.
&& mime != APPLICATION_X_OLE_STORAGE.deref()); && mime != &*APPLICATION_X_OLE_STORAGE);
if r.is_some() { if r.is_some() {
return Ok(r); return Ok(r);

View file

@ -4,7 +4,6 @@
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use std::ffi::OsStr; use std::ffi::OsStr;
use std::ops::Deref;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use clap::Clap; use clap::Clap;
@ -60,10 +59,10 @@ fn recommend_ext() {
&IMAGE_JPEG => "jpg", &IMAGE_JPEG => "jpg",
&IMAGE_PNG => "png", &IMAGE_PNG => "png",
&APPLICATION_PDF => "pdf", &APPLICATION_PDF => "pdf",
APPLICATION_ZIP.deref() => "zip", &*APPLICATION_ZIP => "zip",
]; ];
for (mime, ext) in tests.into_iter() { for (mime, ext) in tests {
assert!( assert!(
mime_extension_lookup(mime.essence_str().into()) mime_extension_lookup(mime.essence_str().into())
.unwrap() .unwrap()
@ -446,7 +445,7 @@ fn writables_is_correct() {
assert_eq!( assert_eq!(
&["henlo".into(), Path::new("henlo").into(), Writable::Newline, Writable::Newline], &["henlo".into(), Path::new("henlo").into(), Writable::Newline, Writable::Newline],
writablesln!["henlo", (Path::new("henlo")), Newline] writablesln!["henlo", (Path::new("henlo")), Newline]
) );
} }
#[test] #[test]