chore: cargo clippy

This commit is contained in:
sigoden 2022-11-10 15:38:35 +08:00
parent dbf2de9cb9
commit bd07783cde
4 changed files with 12 additions and 12 deletions

View file

@ -216,7 +216,7 @@ impl AuthMethod {
let digest_vals = to_headermap(digest_value).ok()?;
digest_vals
.get(b"username".as_ref())
.and_then(|b| std::str::from_utf8(*b).ok())
.and_then(|b| std::str::from_utf8(b).ok())
.map(|v| v.to_string())
}
}
@ -255,7 +255,7 @@ impl AuthMethod {
if let (Some(username), Some(nonce), Some(user_response)) = (
digest_vals
.get(b"username".as_ref())
.and_then(|b| std::str::from_utf8(*b).ok()),
.and_then(|b| std::str::from_utf8(b).ok()),
digest_vals.get(b"nonce".as_ref()),
digest_vals.get(b"response".as_ref()),
) {
@ -278,7 +278,7 @@ impl AuthMethod {
if qop == &b"auth".as_ref() || qop == &b"auth-int".as_ref() {
correct_response = Some({
let mut c = Context::new();
c.consume(&auth_pass);
c.consume(auth_pass);
c.consume(b":");
c.consume(nonce);
c.consume(b":");
@ -301,7 +301,7 @@ impl AuthMethod {
Some(r) => r,
None => {
let mut c = Context::new();
c.consume(&auth_pass);
c.consume(auth_pass);
c.consume(b":");
c.consume(nonce);
c.consume(b":");

View file

@ -593,7 +593,7 @@ impl Server {
None
};
if let Some(mime) = mime_guess::from_path(&path).first() {
if let Some(mime) = mime_guess::from_path(path).first() {
res.headers_mut().typed_insert(ContentType::from(mime));
} else {
res.headers_mut().insert(
@ -902,7 +902,7 @@ impl Server {
Some(path) => path,
None => return None,
};
Some(self.args.path.join(&stripped_path))
Some(self.args.path.join(stripped_path))
}
fn strip_path_prefix<'a, P: AsRef<Path>>(&self, path: &'a P) -> Option<&'a Path> {

View file

@ -125,8 +125,8 @@ impl Accept for TlsAcceptor {
// Load public certificate from file.
pub fn load_certs(filename: &str) -> Result<Vec<Certificate>, Box<dyn std::error::Error>> {
// Open certificate file.
let cert_file = fs::File::open(&filename)
.map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?;
let cert_file =
fs::File::open(filename).map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?;
let mut reader = io::BufReader::new(cert_file);
// Load and return certificate.
@ -139,8 +139,8 @@ pub fn load_certs(filename: &str) -> Result<Vec<Certificate>, Box<dyn std::error
// Load private key from file.
pub fn load_private_key(filename: &str) -> Result<PrivateKey, Box<dyn std::error::Error>> {
let key_file = fs::File::open(&filename)
.map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?;
let key_file =
fs::File::open(filename).map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?;
let mut reader = io::BufReader::new(key_file);
// Load and return a single private key.

View file

@ -34,7 +34,7 @@ fn tls_works(#[case] server: TestServer) -> Result<(), Error> {
#[rstest]
fn wrong_path_cert() -> Result<(), Error> {
Command::cargo_bin("dufs")?
.args(&["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"])
.args(["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"])
.assert()
.failure()
.stderr(contains("error: Failed to access `wrong`"));
@ -46,7 +46,7 @@ fn wrong_path_cert() -> Result<(), Error> {
#[rstest]
fn wrong_path_key() -> Result<(), Error> {
Command::cargo_bin("dufs")?
.args(&["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"])
.args(["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"])
.assert()
.failure()
.stderr(contains("error: Failed to access `wrong`"));