fixed compilation on some obscurish architectures (e.g. powerpc), more clippy lints

This commit is contained in:
Lynne Megido 2021-04-03 03:51:49 +10:00
parent 7115692f9d
commit 25c9efa2f1
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
8 changed files with 28 additions and 9 deletions

View file

@ -26,7 +26,6 @@ xdg-mime-backend = []
[dependencies] [dependencies]
walkdir = "2.3.1" walkdir = "2.3.1"
log = "0.4.14" log = "0.4.14"
smartstring = "0.2.6"
mime_guess = "2.0.3" mime_guess = "2.0.3"
snailquote = "0.3.0" snailquote = "0.3.0"
once_cell = "1.5.2" once_cell = "1.5.2"
@ -38,6 +37,9 @@ cfg-if = "1.0.0"
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
xdg-mime = "0.3" xdg-mime = "0.3"
[target.'cfg(not(all(target_endian = "big", target_pointer_width = "32")))'.dependencies]
smartstring = "0.2.6"
[patch.crates-io] [patch.crates-io]
# use git version while waiting on a release incorporating https://github.com/ebassi/xdg-mime-rs/commit/de5a6dd # use git version while waiting on a release incorporating https://github.com/ebassi/xdg-mime-rs/commit/de5a6dd
xdg-mime = {git = "https://github.com/ebassi/xdg-mime-rs", version = "0.3", rev = "de5a6dd" } xdg-mime = {git = "https://github.com/ebassi/xdg-mime-rs", version = "0.3", rev = "de5a6dd" }

View file

@ -6,6 +6,11 @@ cargo clippy --tests -- \
-W clippy::pedantic \ -W clippy::pedantic \
-W clippy::complexity \ -W clippy::complexity \
-W clippy::cargo \ -W clippy::cargo \
-W clippy::float_cmp_const \
-W clippy::lossy_float_literal \
-W clippy::multiple_inherent_impl \
-W clippy::string_to_string \
-W clippy::wrong_pub_self_convention \
-A clippy::unused_io_amount \ -A clippy::unused_io_amount \
-A clippy::redundant_closure_for_method_calls \ -A clippy::redundant_closure_for_method_calls \
-A clippy::shadow_unrelated -A clippy::shadow_unrelated

View file

@ -1,7 +1,7 @@
use std::path::Path; use std::path::Path;
use crate::string_type::String;
use mime_guess::Mime; use mime_guess::Mime;
use smartstring::alias::String;
use crate::inspectors::mime_extension_lookup; use crate::inspectors::mime_extension_lookup;

View file

@ -8,9 +8,9 @@ use std::str::FromStr;
use cached::cached; use cached::cached;
use mime_guess::Mime; use mime_guess::Mime;
use smartstring::alias::String;
use crate::mime_db::MimeDb; use crate::mime_db::MimeDb;
use crate::string_type::String;
/// The number of bytes to read initially. /// The number of bytes to read initially.
/// ///

View file

@ -41,6 +41,7 @@ mod inspectors;
mod mime_db; mod mime_db;
mod parameters; mod parameters;
mod scan_error; mod scan_error;
pub(crate) mod string_type;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View file

@ -1,11 +1,10 @@
//! [Clap] struct used to parse command line arguments. //! [Clap] struct used to parse command line arguments.
use std::path::PathBuf;
use crate::extension_set::ExtensionSet; use crate::extension_set::ExtensionSet;
use crate::string_type::String as StringType;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use clap::{AppSettings, Clap}; use clap::{AppSettings, Clap};
use smartstring::{LazyCompact, SmartString}; use std::path::PathBuf;
cfg_if! { cfg_if! {
if #[cfg(windows)] { if #[cfg(windows)] {
@ -50,7 +49,7 @@ pub struct Parameters {
require_delimiter = true, require_delimiter = true,
required_unless_present = "ext-set" required_unless_present = "ext-set"
)] )]
pub exts: Option<Vec<SmartString<LazyCompact>>>, pub exts: Option<Vec<StringType>>,
/// Use a preset list of extensions as the search filter /// Use a preset list of extensions as the search filter
#[clap(short = 'E', long, arg_enum, required_unless_present = "exts")] #[clap(short = 'E', long, arg_enum, required_unless_present = "exts")]

11
src/string_type.rs Normal file
View file

@ -0,0 +1,11 @@
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(not(all(target_endian = "big", target_pointer_width = "32")))] {
// most architectures
pub use smartstring::alias::String;
} else {
// powerpc
pub use std::string::String;
}
}

View file

@ -1,12 +1,13 @@
use crate::inspectors::{mime_extension_lookup, BUF_SIZE}; use crate::inspectors::{mime_extension_lookup, BUF_SIZE};
use crate::{extension_from_path, init_db, scan_directory, scan_from_walkdir}; use crate::{extension_from_path, init_db, scan_directory, scan_from_walkdir};
use crate::parameters::{Parameters, ScanOpts};
use crate::mime_db::MimeDb; use crate::mime_db::MimeDb;
use crate::parameters::{Parameters, ScanOpts};
use crate::string_type::String;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use mime_guess::mime::{APPLICATION_OCTET_STREAM, APPLICATION_PDF, IMAGE_JPEG, IMAGE_PNG}; use mime_guess::mime::{APPLICATION_OCTET_STREAM, APPLICATION_PDF, IMAGE_JPEG, IMAGE_PNG};
use mime_guess::Mime; use mime_guess::Mime;
use smartstring::alias::String;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::OsStr; use std::ffi::OsStr;