diff --git a/src/explorer/mod.rs b/src/explorer/mod.rs index bbdad62..cfb119e 100644 --- a/src/explorer/mod.rs +++ b/src/explorer/mod.rs @@ -10,7 +10,6 @@ use std::cmp::Reverse; use std::collections::VecDeque; use std::path::{Path, PathBuf}; use std::str::FromStr; -use std::string::ToString; use formatter::Formatter; // Ext @@ -243,14 +242,18 @@ impl FileExplorer { // Traits -impl ToString for FileSorting { - fn to_string(&self) -> String { - String::from(match self { - FileSorting::CreationTime => "by_creation_time", - FileSorting::ModifyTime => "by_mtime", - FileSorting::Name => "by_name", - FileSorting::Size => "by_size", - }) +impl std::fmt::Display for FileSorting { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + FileSorting::CreationTime => "by_creation_time", + FileSorting::ModifyTime => "by_mtime", + FileSorting::Name => "by_name", + FileSorting::Size => "by_size", + } + ) } } @@ -267,12 +270,16 @@ impl FromStr for FileSorting { } } -impl ToString for GroupDirs { - fn to_string(&self) -> String { - String::from(match self { - GroupDirs::First => "first", - GroupDirs::Last => "last", - }) +impl std::fmt::Display for GroupDirs { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + GroupDirs::First => "first", + GroupDirs::Last => "last", + } + ) } } diff --git a/src/filetransfer/mod.rs b/src/filetransfer/mod.rs index a9d6cd2..ab9ddab 100644 --- a/src/filetransfer/mod.rs +++ b/src/filetransfer/mod.rs @@ -23,19 +23,23 @@ pub enum FileTransferProtocol { // Traits -impl std::string::ToString for FileTransferProtocol { - fn to_string(&self) -> String { - String::from(match self { - FileTransferProtocol::AwsS3 => "S3", - FileTransferProtocol::Ftp(secure) => match secure { - true => "FTPS", - false => "FTP", - }, - FileTransferProtocol::Scp => "SCP", - FileTransferProtocol::Sftp => "SFTP", - FileTransferProtocol::Smb => "SMB", - FileTransferProtocol::WebDAV => "WEBDAV", - }) +impl std::fmt::Display for FileTransferProtocol { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + FileTransferProtocol::AwsS3 => "S3", + FileTransferProtocol::Ftp(secure) => match secure { + true => "FTPS", + false => "FTP", + }, + FileTransferProtocol::Scp => "SCP", + FileTransferProtocol::Sftp => "SFTP", + FileTransferProtocol::Smb => "SMB", + FileTransferProtocol::WebDAV => "WEBDAV", + } + ) } } diff --git a/src/ui/store.rs b/src/ui/store.rs index 68f5ed5..8fd24ca 100644 --- a/src/ui/store.rs +++ b/src/ui/store.rs @@ -81,7 +81,7 @@ impl Store { /// Check if a state is set in the store pub fn isset(&self, key: &str) -> bool { - self.store.get(key).is_some() + self.store.contains_key(key) } // -- setters