From f32a90e89673040c1539dc512fb16d6dadf04098 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Tue, 4 Dec 2018 13:56:51 +0200 Subject: [PATCH] Fix clippy warnings --- src/block.rs | 3 ++- src/error.rs | 2 +- src/mountstack.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/block.rs b/src/block.rs index a02297c..dc9503b 100644 --- a/src/block.rs +++ b/src/block.rs @@ -16,13 +16,14 @@ impl BlockDevice { .file_name() .and_then(|s| s.to_str()) .map(String::from) - .ok_or(Error::from(ErrorKind::InvalidDeviceName))?; + .ok_or_else(|| Error::from(ErrorKind::InvalidDeviceName))?; debug!( "path: {:?}, real path: {:?}, device name: {:?}", path, real_path, device_name ); + drop(path); let _self = Self { name: device_name }; if !(_self.is_removable()? || _self.is_loop_device()) { return Err(ErrorKind::DangerousDevice)?; diff --git a/src/error.rs b/src/error.rs index 3588222..517b2e9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -95,6 +95,6 @@ impl From for Error { impl From> for Error { fn from(inner: Context) -> Error { - Error { inner: inner } + Error { inner } } } diff --git a/src/mountstack.rs b/src/mountstack.rs index 787430a..35639fd 100644 --- a/src/mountstack.rs +++ b/src/mountstack.rs @@ -6,14 +6,14 @@ use nix::mount::{mount, umount, MsFlags}; use std::borrow::Cow; use std::path::Path; -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub enum Filesystem { Ext4, Vfat, } impl Filesystem { - fn to_type(&self) -> &'static str { + fn to_type(self) -> &'static str { match self { Filesystem::Ext4 => "ext4", Filesystem::Vfat => "vfat",