1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-24 22:37:35 +02:00

rust 1.64 clippy run (#2891)

This commit is contained in:
Rob Ede
2022-09-25 20:54:17 +01:00
committed by GitHub
parent 172c4c7a0a
commit cc7145d41d
24 changed files with 58 additions and 67 deletions

View File

@ -131,7 +131,7 @@ mod foreign_impls {
type Error = B::Error;
fn size(&self) -> BodySize {
(&**self).size()
(**self).size()
}
fn poll_next(

View File

@ -42,7 +42,7 @@ pub async fn to_bytes<B: MessageBody>(body: B) -> Result<Bytes, B::Error> {
let body = body.as_mut();
match ready!(body.poll_next(cx)) {
Some(Ok(bytes)) => buf.extend_from_slice(&*bytes),
Some(Ok(bytes)) => buf.extend_from_slice(&bytes),
None => return Poll::Ready(Ok(())),
Some(Err(err)) => return Poll::Ready(Err(err)),
}

View File

@ -637,7 +637,7 @@ async fn expect_handling() {
if let DispatcherState::Normal { ref inner } = h1.inner {
let io = inner.io.as_ref().unwrap();
let mut res = (&io.write_buf()[..]).to_owned();
let mut res = io.write_buf()[..].to_owned();
stabilize_date_header(&mut res);
assert_eq!(
@ -699,7 +699,7 @@ async fn expect_eager() {
if let DispatcherState::Normal { ref inner } = h1.inner {
let io = inner.io.as_ref().unwrap();
let mut res = (&io.write_buf()[..]).to_owned();
let mut res = io.write_buf()[..].to_owned();
stabilize_date_header(&mut res);
// Despite the content-length header and even though the request payload has not

View File

@ -309,7 +309,7 @@ impl HeaderMap {
pub fn get_all(&self, key: impl AsHeaderName) -> std::slice::Iter<'_, HeaderValue> {
match self.get_value(key) {
Some(value) => value.iter(),
None => (&[]).iter(),
None => [].iter(),
}
}

View File

@ -113,14 +113,14 @@ impl<P> Request<P> {
#[inline]
/// Http message part of the request
pub fn head(&self) -> &RequestHead {
&*self.head
&self.head
}
#[inline]
#[doc(hidden)]
/// Mutable reference to a HTTP message part of the request
pub fn head_mut(&mut self) -> &mut RequestHead {
&mut *self.head
&mut self.head
}
/// Mutable reference to the message's headers.

View File

@ -83,13 +83,13 @@ impl<B> Response<B> {
/// Returns a reference to the head of this response.
#[inline]
pub fn head(&self) -> &ResponseHead {
&*self.head
&self.head
}
/// Returns a mutable reference to the head of this response.
#[inline]
pub fn head_mut(&mut self) -> &mut ResponseHead {
&mut *self.head
&mut self.head
}
/// Returns the status code of this response.

View File

@ -313,7 +313,7 @@ mod tests {
#[test]
fn test_parse_frame_no_mask() {
let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]);
buf.extend(&[1u8]);
buf.extend([1u8]);
assert!(Parser::parse(&mut buf, true, 1024).is_err());
@ -326,7 +326,7 @@ mod tests {
#[test]
fn test_parse_frame_max_size() {
let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0010u8][..]);
buf.extend(&[1u8, 1u8]);
buf.extend([1u8, 1u8]);
assert!(Parser::parse(&mut buf, true, 1).is_err());
@ -340,9 +340,9 @@ mod tests {
fn test_parse_frame_max_size_recoverability() {
let mut buf = BytesMut::new();
// The first text frame with length == 2, payload doesn't matter.
buf.extend(&[0b0000_0001u8, 0b0000_0010u8, 0b0000_0000u8, 0b0000_0000u8]);
buf.extend([0b0000_0001u8, 0b0000_0010u8, 0b0000_0000u8, 0b0000_0000u8]);
// Next binary frame with length == 2 and payload == `[0x1111_1111u8, 0x1111_1111u8]`.
buf.extend(&[0b0000_0010u8, 0b0000_0010u8, 0b1111_1111u8, 0b1111_1111u8]);
buf.extend([0b0000_0010u8, 0b0000_0010u8, 0b1111_1111u8, 0b1111_1111u8]);
assert_eq!(buf.len(), 8);
assert!(matches!(

View File

@ -244,7 +244,7 @@ pub fn hash_key(key: &[u8]) -> [u8; 28] {
};
let mut hash_b64 = [0; 28];
let n = base64::encode_config_slice(&hash, base64::STANDARD, &mut hash_b64);
let n = base64::encode_config_slice(hash, base64::STANDARD, &mut hash_b64);
assert_eq!(n, 28);
hash_b64

View File

@ -41,7 +41,7 @@ where
let body = stream.as_mut();
match ready!(body.poll_next(cx)) {
Some(Ok(bytes)) => buf.extend_from_slice(&*bytes),
Some(Ok(bytes)) => buf.extend_from_slice(&bytes),
None => return Poll::Ready(Ok(())),
Some(Err(err)) => return Poll::Ready(Err(err)),
}