Fix clippy warnings.

This commit is contained in:
Sergiu Puscas
2021-04-05 18:41:17 +02:00
parent 30ea80bf31
commit 6ec46827e7
2 changed files with 27 additions and 33 deletions

View File

@@ -1,4 +1,3 @@
use std;
use std::error;
use std::fmt::{self, Display};
use std::io::{self, Cursor, Read, Seek, SeekFrom, Write};
@@ -9,18 +8,16 @@ use std::time::Duration;
use itertools::Itertools;
use hyper;
use hyper::header::{HeaderMap, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT};
use hyper::Method;
use hyper::StatusCode;
use hyper::body::Buf;
use mime::{Attr, Mime, SubLevel, TopLevel, Value};
use oauth2;
use serde_json as json;
const LINE_ENDING: &'static str = "\r\n";
const LINE_ENDING: &str = "\r\n";
pub enum Retry {
/// Signal you don't want to retry
@@ -306,9 +303,9 @@ impl Display for Error {
err.domain,
err.message,
err.reason,
match &err.location {
&Some(ref loc) => format!("@{}", loc),
&None => String::new(),
match err.location {
Some(ref loc) => format!("@{}", loc),
None => String::new(),
}
)?;
}
@@ -356,7 +353,7 @@ pub struct MethodInfo {
pub http_method: Method,
}
const BOUNDARY: &'static str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d";
const BOUNDARY: &str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d";
/// Provides a `Read` interface that converts multiple parts into the protocol
/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387).
@@ -417,14 +414,14 @@ impl<'a> MultiPartReader<'a> {
/// Returns true if we are totally used
fn is_depleted(&self) -> bool {
self.raw_parts.len() == 0
self.raw_parts.is_empty()
&& self.current_part.is_none()
&& self.last_part_boundary.is_none()
}
/// Returns true if we are handling our last part
fn is_last_part(&self) -> bool {
self.raw_parts.len() == 0 && self.current_part.is_some()
self.raw_parts.is_empty() && self.current_part.is_some()
}
}
@@ -519,12 +516,12 @@ pub struct XUploadContentType(pub Mime);
impl ::std::ops::Deref for XUploadContentType {
type Target = Mime;
fn deref<'a>(&'a self) -> &'a Mime {
fn deref(&self) -> &Mime {
&self.0
}
}
impl ::std::ops::DerefMut for XUploadContentType {
fn deref_mut<'a>(&'a mut self) -> &'a mut Mime {
fn deref_mut(&mut self) -> &mut Mime {
&mut self.0
}
}
@@ -594,11 +591,11 @@ pub struct RangeResponseHeader(pub Chunk);
impl RangeResponseHeader {
fn from_bytes(raw: &[u8]) -> Self {
if raw.len() > 0 {
if !raw.is_empty() {
if let Ok(s) = std::str::from_utf8(raw) {
const PREFIX: &'static str = "bytes ";
if s.starts_with(PREFIX) {
if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) {
const PREFIX: &str = "bytes ";
if let Some(stripped) = s.strip_prefix(PREFIX) {
if let Ok(c) = <Chunk as FromStr>::from_str(&stripped) {
return RangeResponseHeader(c);
}
}