clippy fix
This commit is contained in:
parent
11515a4158
commit
655db21ef4
4 changed files with 44 additions and 31 deletions
19
.vscode/tasks.json
vendored
19
.vscode/tasks.json
vendored
|
|
@ -27,15 +27,24 @@
|
|||
"group": "none"
|
||||
},
|
||||
{
|
||||
"label": "Clippy Fix Project",
|
||||
"label": "Clippy All Targets",
|
||||
"type": "cargo",
|
||||
"command": "clippy",
|
||||
"args": [
|
||||
"--all-targets",
|
||||
"--",
|
||||
"-Wclippy::pedantic"
|
||||
],
|
||||
"problemMatcher": "$rustc",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "Clippy Fix All Targets",
|
||||
"type": "cargo",
|
||||
"command": "clippy",
|
||||
"args": [
|
||||
"--fix",
|
||||
"--lib",
|
||||
"--bin",
|
||||
"shrupl",
|
||||
"--allow-dirty",
|
||||
"--all-targets",
|
||||
"--allow-staged",
|
||||
"--",
|
||||
"-Wclippy::pedantic"
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub const DATA_LENGTHS_BAD: [u64; 8] = [36, 12, 1, 0, 9, 24, 13, 10];
|
|||
|
||||
/// known good hashes of the test dataset
|
||||
///
|
||||
/// using BLAKE2b, 512 bit, with unpadded Base64 (standard variant)
|
||||
/// using `BLAKE2b`, 512 bit, with unpadded Base64 (standard variant)
|
||||
pub const HASHES_STD_GOOD: [&str; 8] = [
|
||||
// empty slice
|
||||
"eGoC90IBWQPGxv2FJVLScpEvR0DhWEdhiobiF/cfVBnSXhAxr+5YUxOJZESTTrBLkDpoWxRIt1XVb3Aa/pvizg",
|
||||
|
|
@ -101,7 +101,7 @@ pub const HASHES_STD_BAD: [&str; 8] = [
|
|||
// ];
|
||||
|
||||
pub fn data() -> impl Iterator<Item = &'static [u8]> {
|
||||
DATA.iter().map(|item| *item)
|
||||
DATA.iter().copied()
|
||||
}
|
||||
|
||||
pub fn cases() -> impl Iterator<Item = (&'static [u8], u64)> {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use crate::{
|
|||
sharry::{AliasID, FileID, ShareID, Uri},
|
||||
};
|
||||
|
||||
const VALID_URI: &'static str = "scheme://valid.uri";
|
||||
const VALID_ALIAS: &'static str = "valid-alias";
|
||||
const VALID_SHARE: &'static str = "valid-share";
|
||||
const VALID_FILE: &'static str = "valid-file";
|
||||
const VALID_URI: &str = "scheme://valid.uri";
|
||||
const VALID_ALIAS: &str = "valid-alias";
|
||||
const VALID_SHARE: &str = "valid-share";
|
||||
const VALID_FILE: &str = "valid-file";
|
||||
|
||||
pub trait CheckID {
|
||||
fn check(self) -> Result<()>;
|
||||
|
|
@ -26,10 +26,10 @@ impl CheckID for (&Uri, &AliasID) {
|
|||
|
||||
impl CheckID for &ShareID {
|
||||
fn check(self) -> Result<()> {
|
||||
if self.to_string() != VALID_SHARE {
|
||||
Err(self.into())
|
||||
} else {
|
||||
if self.to_string() == VALID_SHARE {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(self.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,10 +38,10 @@ impl CheckID for (&ShareID, &FileID) {
|
|||
fn check(self) -> Result<()> {
|
||||
self.0.check()?;
|
||||
|
||||
if self.1.to_string() != VALID_FILE {
|
||||
Err(self.1.into())
|
||||
} else {
|
||||
if self.1.to_string() == VALID_FILE {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(self.1.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -55,36 +55,40 @@ fn make_invalid(valid: &str) -> String {
|
|||
|
||||
impl From<bool> for Uri {
|
||||
fn from(value: bool) -> Self {
|
||||
match value {
|
||||
true => Self::from(VALID_URI.to_string()),
|
||||
false => Self::from(make_invalid(VALID_URI)),
|
||||
if value {
|
||||
Self::from(VALID_URI.to_string())
|
||||
} else {
|
||||
Self::from(make_invalid(VALID_URI))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bool> for AliasID {
|
||||
fn from(value: bool) -> Self {
|
||||
match value {
|
||||
true => Self::from(VALID_ALIAS.to_string()),
|
||||
false => Self::from(make_invalid(VALID_ALIAS)),
|
||||
if value {
|
||||
Self::from(VALID_ALIAS.to_string())
|
||||
} else {
|
||||
Self::from(make_invalid(VALID_ALIAS))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bool> for ShareID {
|
||||
fn from(value: bool) -> Self {
|
||||
match value {
|
||||
true => Self::from(VALID_SHARE.to_string()),
|
||||
false => Self::from(make_invalid(VALID_SHARE)),
|
||||
if value {
|
||||
Self::from(VALID_SHARE.to_string())
|
||||
} else {
|
||||
Self::from(make_invalid(VALID_SHARE))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bool> for FileID {
|
||||
fn from(value: bool) -> Self {
|
||||
match value {
|
||||
true => Self::new_test(VALID_FILE),
|
||||
false => Self::new_test(make_invalid(VALID_FILE)),
|
||||
if value {
|
||||
Self::new_test(VALID_FILE)
|
||||
} else {
|
||||
Self::new_test(make_invalid(VALID_FILE))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use std::{fmt, io::Write};
|
|||
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
pub fn check_trait<A, E>(actual: A, expected: E, tr: &str, ty: &str)
|
||||
where
|
||||
A: fmt::Debug + PartialEq<E>,
|
||||
|
|
@ -15,8 +16,7 @@ where
|
|||
{
|
||||
assert_eq!(
|
||||
actual, expected,
|
||||
"`impl {tr} for {ty}` expected: {:?}, actual: {:?}",
|
||||
expected, actual,
|
||||
"`impl {tr} for {ty}` expected: {expected:?}, actual: {actual:?}",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue