replace fastrand dep with rand, rustfmt
This commit is contained in:
parent
a60a19191a
commit
beebbbbb3b
4 changed files with 34 additions and 34 deletions
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -182,15 +182,6 @@ version = "1.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77b705829d1e87f762c2df6da140b26af5839e1033aa84aa5f56bb688e4e1bdb"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fif"
|
||||
version = "0.3.0"
|
||||
|
@ -200,12 +191,12 @@ dependencies = [
|
|||
"clap",
|
||||
"env_logger",
|
||||
"exitcode",
|
||||
"fastrand",
|
||||
"infer",
|
||||
"itertools",
|
||||
"log",
|
||||
"new_mime_guess",
|
||||
"once_cell",
|
||||
"rand",
|
||||
"rayon",
|
||||
"smartstring",
|
||||
"snailquote",
|
||||
|
@ -274,15 +265,6 @@ dependencies = [
|
|||
"cfb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.0"
|
||||
|
|
|
@ -57,7 +57,7 @@ default-features = false
|
|||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.2.0"
|
||||
fastrand = "1.4.1"
|
||||
rand = "0.8.3"
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
|
|
|
@ -54,7 +54,14 @@ pub struct Parameters {
|
|||
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||
/// `media` includes all extensions from the `audio`, `video`, and `images` sets, making `-E media` equivalent to
|
||||
/// `-E audio,video,images`.
|
||||
#[clap(short = 'E', long, arg_enum, use_delimiter = true, require_delimiter = true, value_name = "set")]
|
||||
#[clap(
|
||||
short = 'E',
|
||||
long,
|
||||
arg_enum,
|
||||
use_delimiter = true,
|
||||
require_delimiter = true,
|
||||
value_name = "set"
|
||||
)]
|
||||
pub ext_set: Vec<ExtensionSet>,
|
||||
|
||||
/// Don't scan files with these extensions.
|
||||
|
@ -64,7 +71,14 @@ pub struct Parameters {
|
|||
|
||||
/// Exclude files using a preset list of extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'X', long, arg_enum, use_delimiter = true, require_delimiter = true, value_name = "set")]
|
||||
#[clap(
|
||||
short = 'X',
|
||||
long,
|
||||
arg_enum,
|
||||
use_delimiter = true,
|
||||
require_delimiter = true,
|
||||
value_name = "set"
|
||||
)]
|
||||
pub exclude_set: Vec<ExtensionSet>,
|
||||
|
||||
/// Don't skip hidden files and directories.
|
||||
|
@ -106,7 +120,7 @@ pub struct Parameters {
|
|||
fn lowercase_exts(exts: &str) -> Result<(), String> {
|
||||
// TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts...
|
||||
if exts.to_lowercase() != exts {
|
||||
return Err(String::from("Supplied extensions must be lowercase"))
|
||||
return Err(String::from("Supplied extensions must be lowercase"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -197,14 +211,14 @@ impl Parameters {
|
|||
match self.quiet {
|
||||
0 => {
|
||||
match self.verbose {
|
||||
0 => "info", // no verbosity flags specified
|
||||
0 => "info", // no verbosity flags specified
|
||||
1 => "debug", // -v
|
||||
_ => "trace" // -vv...
|
||||
_ => "trace", // -vv...
|
||||
}
|
||||
},
|
||||
1 => "warn", // -q
|
||||
}
|
||||
1 => "warn", // -q
|
||||
2 => "error", // -qq
|
||||
_ => "off" // -qqq...
|
||||
_ => "off", // -qqq...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,14 +304,15 @@ fn rejects_bad_args() {
|
|||
/// Generate random series of bytes and try to identify them. This test makes no assertions and can only fail if the
|
||||
/// mime database somehow panics or hangs.
|
||||
fn identify_random_bytes() {
|
||||
use rand::RngCore;
|
||||
let db = get_mime_db();
|
||||
let rng = fastrand::Rng::new();
|
||||
let mut bytes: Vec<u8>;
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut bytes: [u8; BUF_SIZE * 2] = [0; BUF_SIZE * 2];
|
||||
let mut results: HashMap<Mime, i32> = HashMap::new();
|
||||
|
||||
for _ in 1..500 {
|
||||
bytes = std::iter::repeat_with(|| rng.u8(..)).take(BUF_SIZE * 2).collect();
|
||||
if let Some(detected_type) = db.get_type(&*bytes) {
|
||||
for _ in 1..1000 {
|
||||
rng.fill_bytes(&mut bytes);
|
||||
if let Some(detected_type) = db.get_type(&bytes) {
|
||||
*results.entry(detected_type).or_insert(0) += 1;
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +392,10 @@ fn writables_is_correct() {
|
|||
#[test]
|
||||
/// Test various combinations of verbosity flags.
|
||||
fn verbosity() {
|
||||
assert!(Parameters::try_parse_from(&["fif", "-q", "-v"]).is_err(), "Failed to reject usage of both -q and -v!");
|
||||
assert!(
|
||||
Parameters::try_parse_from(&["fif", "-q", "-v"]).is_err(),
|
||||
"Failed to reject usage of both -q and -v!"
|
||||
);
|
||||
|
||||
let mut expected_results = HashMap::new();
|
||||
expected_results.insert("-qqqqqqqq", "off");
|
||||
|
|
Loading…
Reference in a new issue