From c890be193652311f6cc96e1099652a17af39179a Mon Sep 17 00:00:00 2001 From: Zvonko Kaiser Date: Thu, 6 Jun 2024 08:24:08 +0000 Subject: [PATCH] Fix Display and assert_eq for clippy Signed-off-by: Zvonko Kaiser --- src/container_edits_unix.rs | 16 +++++++++------- src/parser.rs | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/container_edits_unix.rs b/src/container_edits_unix.rs index 64e2664..5da3070 100644 --- a/src/container_edits_unix.rs +++ b/src/container_edits_unix.rs @@ -2,6 +2,7 @@ use std::{ io::{Error, ErrorKind}, os::unix::fs::{FileTypeExt, MetadataExt}, path::Path, + fmt, }; use anyhow::Result; @@ -12,13 +13,14 @@ pub enum DeviceType { Fifo, } -impl ToString for DeviceType { - fn to_string(&self) -> String { - match self { - DeviceType::Block => "b".to_string(), - DeviceType::Char => "c".to_string(), - DeviceType::Fifo => "p".to_string(), - } +impl fmt::Display for DeviceType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s = match self { + DeviceType::Block => "b", + DeviceType::Char => "c", + DeviceType::Fifo => "p", + }; + write!(f, "{}", s) } } diff --git a/src/parser.rs b/src/parser.rs index 736bc9f..8d15066 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -177,7 +177,7 @@ mod tests { let name = "0"; let device = parser::qualified_name(vendor, class, name); assert_eq!(device, "nvidia.com/gpu=0"); - assert_eq!(parser::is_qualified_name(&device), true); + assert!(parser::is_qualified_name(&device)); } #[test]