From ce859656ec7687058eb3828ce0217a33fb4a6d80 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 7 Jul 2020 09:44:50 +0200 Subject: [PATCH] some minor clippy lint cleanups Signed-off-by: Wolfgang Bumiller --- proxmox/src/sys/linux/procfs.rs | 1 - proxmox/src/sys/linux/procfs/mountinfo.rs | 4 ++-- proxmox/src/sys/linux/tty.rs | 4 ++-- proxmox/src/tools/mod.rs | 2 +- proxmox/src/tools/serde.rs | 2 -- proxmox/src/tools/websocket.rs | 6 +++--- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/proxmox/src/sys/linux/procfs.rs b/proxmox/src/sys/linux/procfs.rs index 45ba779d..6cca3071 100644 --- a/proxmox/src/sys/linux/procfs.rs +++ b/proxmox/src/sys/linux/procfs.rs @@ -10,7 +10,6 @@ use std::time::Instant; use anyhow::*; use lazy_static::lazy_static; -use libc; use nix::unistd::Pid; use crate::tools::fs::file_read_firstline; diff --git a/proxmox/src/sys/linux/procfs/mountinfo.rs b/proxmox/src/sys/linux/procfs/mountinfo.rs index 1384c089..55f74c2f 100644 --- a/proxmox/src/sys/linux/procfs/mountinfo.rs +++ b/proxmox/src/sys/linux/procfs/mountinfo.rs @@ -253,7 +253,7 @@ impl<'a> IntoIterator for &'a MountInfo { type IntoIter = Iter<'a>; fn into_iter(self) -> Self::IntoIter { - (&self.entries).into_iter() + self.entries.iter() } } @@ -262,7 +262,7 @@ impl<'a> IntoIterator for &'a mut MountInfo { type IntoIter = IterMut<'a>; fn into_iter(self) -> Self::IntoIter { - (&mut self.entries).into_iter() + self.entries.iter_mut() } } diff --git a/proxmox/src/sys/linux/tty.rs b/proxmox/src/sys/linux/tty.rs index aadd500b..518cc39f 100644 --- a/proxmox/src/sys/linux/tty.rs +++ b/proxmox/src/sys/linux/tty.rs @@ -135,7 +135,7 @@ pub fn read_password(query: &str) -> Result, Error> { 9 => asterisks = false, // tab disables echo 0xA | 0xD => { // newline, we're done - let _ignore_error = out.write_all("\r\n".as_bytes()); + let _ignore_error = out.write_all(b"\r\n"); let _ignore_error = out.flush(); break; } @@ -144,7 +144,7 @@ pub fn read_password(query: &str) -> Result, Error> { if !password.is_empty() { password.pop(); if asterisks { - let _ignore_error = out.write_all("\x08 \x08".as_bytes()); + let _ignore_error = out.write_all(b"\x08 \x08"); let _ignore_error = out.flush(); } } diff --git a/proxmox/src/tools/mod.rs b/proxmox/src/tools/mod.rs index 0675d9ab..bf60ddd2 100644 --- a/proxmox/src/tools/mod.rs +++ b/proxmox/src/tools/mod.rs @@ -97,7 +97,7 @@ impl AsHex<'_> { self.0.len() * 2 } - pub fn to_string(self) -> String { + pub fn to_hex_string(self) -> String { use std::fmt::Write; let mut s = String::with_capacity(self.display_len()); write!(&mut s, "{}", self).expect("failed to format hex string"); diff --git a/proxmox/src/tools/serde.rs b/proxmox/src/tools/serde.rs index 9e04b751..4e6216f0 100644 --- a/proxmox/src/tools/serde.rs +++ b/proxmox/src/tools/serde.rs @@ -73,8 +73,6 @@ pub mod date_time_as_rfc3339 { /// assert_eq!(obj, deserialized); /// ``` pub mod bytes_as_base64 { - - use base64; use serde::{Deserialize, Deserializer, Serializer}; pub fn serialize(data: &T, serializer: S) -> Result diff --git a/proxmox/src/tools/websocket.rs b/proxmox/src/tools/websocket.rs index b1844cab..3877e4e9 100644 --- a/proxmox/src/tools/websocket.rs +++ b/proxmox/src/tools/websocket.rs @@ -38,7 +38,7 @@ pub enum OpCode { impl OpCode { /// Tells whether it is a control frame or not pub fn is_control(self) -> bool { - return self as u8 & 0b1000 > 0; + (self as u8 & 0b1000) > 0 } } @@ -187,7 +187,7 @@ impl WebSocketWriter { /// and mark the frames as either 'Text' or 'Binary' pub fn new(mask: Option<[u8; 4]>, text: bool, writer: W) -> WebSocketWriter { WebSocketWriter { - writer: writer, + writer, text, mask, frame: None, @@ -265,7 +265,7 @@ pub struct FrameHeader { impl FrameHeader { /// Returns true if the frame is a control frame. pub fn is_control_frame(&self) -> bool { - return self.frametype.is_control(); + self.frametype.is_control() } /// Tries to parse a FrameHeader from bytes.