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"
|
"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",
|
"type": "cargo",
|
||||||
"command": "clippy",
|
"command": "clippy",
|
||||||
"args": [
|
"args": [
|
||||||
"--fix",
|
"--fix",
|
||||||
"--lib",
|
"--all-targets",
|
||||||
"--bin",
|
|
||||||
"shrupl",
|
|
||||||
"--allow-dirty",
|
|
||||||
"--allow-staged",
|
"--allow-staged",
|
||||||
"--",
|
"--",
|
||||||
"-Wclippy::pedantic"
|
"-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
|
/// 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] = [
|
pub const HASHES_STD_GOOD: [&str; 8] = [
|
||||||
// empty slice
|
// empty slice
|
||||||
"eGoC90IBWQPGxv2FJVLScpEvR0DhWEdhiobiF/cfVBnSXhAxr+5YUxOJZESTTrBLkDpoWxRIt1XVb3Aa/pvizg",
|
"eGoC90IBWQPGxv2FJVLScpEvR0DhWEdhiobiF/cfVBnSXhAxr+5YUxOJZESTTrBLkDpoWxRIt1XVb3Aa/pvizg",
|
||||||
|
|
@ -101,7 +101,7 @@ pub const HASHES_STD_BAD: [&str; 8] = [
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
pub fn data() -> impl Iterator<Item = &'static [u8]> {
|
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)> {
|
pub fn cases() -> impl Iterator<Item = (&'static [u8], u64)> {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ use crate::{
|
||||||
sharry::{AliasID, FileID, ShareID, Uri},
|
sharry::{AliasID, FileID, ShareID, Uri},
|
||||||
};
|
};
|
||||||
|
|
||||||
const VALID_URI: &'static str = "scheme://valid.uri";
|
const VALID_URI: &str = "scheme://valid.uri";
|
||||||
const VALID_ALIAS: &'static str = "valid-alias";
|
const VALID_ALIAS: &str = "valid-alias";
|
||||||
const VALID_SHARE: &'static str = "valid-share";
|
const VALID_SHARE: &str = "valid-share";
|
||||||
const VALID_FILE: &'static str = "valid-file";
|
const VALID_FILE: &str = "valid-file";
|
||||||
|
|
||||||
pub trait CheckID {
|
pub trait CheckID {
|
||||||
fn check(self) -> Result<()>;
|
fn check(self) -> Result<()>;
|
||||||
|
|
@ -26,10 +26,10 @@ impl CheckID for (&Uri, &AliasID) {
|
||||||
|
|
||||||
impl CheckID for &ShareID {
|
impl CheckID for &ShareID {
|
||||||
fn check(self) -> Result<()> {
|
fn check(self) -> Result<()> {
|
||||||
if self.to_string() != VALID_SHARE {
|
if self.to_string() == VALID_SHARE {
|
||||||
Err(self.into())
|
|
||||||
} else {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(self.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,10 +38,10 @@ impl CheckID for (&ShareID, &FileID) {
|
||||||
fn check(self) -> Result<()> {
|
fn check(self) -> Result<()> {
|
||||||
self.0.check()?;
|
self.0.check()?;
|
||||||
|
|
||||||
if self.1.to_string() != VALID_FILE {
|
if self.1.to_string() == VALID_FILE {
|
||||||
Err(self.1.into())
|
|
||||||
} else {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(self.1.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,36 +55,40 @@ fn make_invalid(valid: &str) -> String {
|
||||||
|
|
||||||
impl From<bool> for Uri {
|
impl From<bool> for Uri {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
match value {
|
if value {
|
||||||
true => Self::from(VALID_URI.to_string()),
|
Self::from(VALID_URI.to_string())
|
||||||
false => Self::from(make_invalid(VALID_URI)),
|
} else {
|
||||||
|
Self::from(make_invalid(VALID_URI))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bool> for AliasID {
|
impl From<bool> for AliasID {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
match value {
|
if value {
|
||||||
true => Self::from(VALID_ALIAS.to_string()),
|
Self::from(VALID_ALIAS.to_string())
|
||||||
false => Self::from(make_invalid(VALID_ALIAS)),
|
} else {
|
||||||
|
Self::from(make_invalid(VALID_ALIAS))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bool> for ShareID {
|
impl From<bool> for ShareID {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
match value {
|
if value {
|
||||||
true => Self::from(VALID_SHARE.to_string()),
|
Self::from(VALID_SHARE.to_string())
|
||||||
false => Self::from(make_invalid(VALID_SHARE)),
|
} else {
|
||||||
|
Self::from(make_invalid(VALID_SHARE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bool> for FileID {
|
impl From<bool> for FileID {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
match value {
|
if value {
|
||||||
true => Self::new_test(VALID_FILE),
|
Self::new_test(VALID_FILE)
|
||||||
false => Self::new_test(make_invalid(VALID_FILE)),
|
} else {
|
||||||
|
Self::new_test(make_invalid(VALID_FILE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use std::{fmt, io::Write};
|
||||||
|
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
pub fn check_trait<A, E>(actual: A, expected: E, tr: &str, ty: &str)
|
pub fn check_trait<A, E>(actual: A, expected: E, tr: &str, ty: &str)
|
||||||
where
|
where
|
||||||
A: fmt::Debug + PartialEq<E>,
|
A: fmt::Debug + PartialEq<E>,
|
||||||
|
|
@ -15,8 +16,7 @@ where
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual, expected,
|
actual, expected,
|
||||||
"`impl {tr} for {ty}` expected: {:?}, actual: {:?}",
|
"`impl {tr} for {ty}` expected: {expected:?}, actual: {actual:?}",
|
||||||
expected, actual,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue