fix: lint

This commit is contained in:
veeso
2024-07-08 14:48:03 +02:00
parent 4f3b97b198
commit 88cdae79a8
3 changed files with 40 additions and 29 deletions

View File

@@ -10,7 +10,6 @@ use std::cmp::Reverse;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use std::string::ToString;
use formatter::Formatter; use formatter::Formatter;
// Ext // Ext
@@ -243,14 +242,18 @@ impl FileExplorer {
// Traits // Traits
impl ToString for FileSorting { impl std::fmt::Display for FileSorting {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
String::from(match self { write!(
FileSorting::CreationTime => "by_creation_time", f,
FileSorting::ModifyTime => "by_mtime", "{}",
FileSorting::Name => "by_name", match self {
FileSorting::Size => "by_size", 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 { impl std::fmt::Display for GroupDirs {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
String::from(match self { write!(
GroupDirs::First => "first", f,
GroupDirs::Last => "last", "{}",
}) match self {
GroupDirs::First => "first",
GroupDirs::Last => "last",
}
)
} }
} }

View File

@@ -23,19 +23,23 @@ pub enum FileTransferProtocol {
// Traits // Traits
impl std::string::ToString for FileTransferProtocol { impl std::fmt::Display for FileTransferProtocol {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
String::from(match self { write!(
FileTransferProtocol::AwsS3 => "S3", f,
FileTransferProtocol::Ftp(secure) => match secure { "{}",
true => "FTPS", match self {
false => "FTP", FileTransferProtocol::AwsS3 => "S3",
}, FileTransferProtocol::Ftp(secure) => match secure {
FileTransferProtocol::Scp => "SCP", true => "FTPS",
FileTransferProtocol::Sftp => "SFTP", false => "FTP",
FileTransferProtocol::Smb => "SMB", },
FileTransferProtocol::WebDAV => "WEBDAV", FileTransferProtocol::Scp => "SCP",
}) FileTransferProtocol::Sftp => "SFTP",
FileTransferProtocol::Smb => "SMB",
FileTransferProtocol::WebDAV => "WEBDAV",
}
)
} }
} }

View File

@@ -81,7 +81,7 @@ impl Store {
/// Check if a state is set in the store /// Check if a state is set in the store
pub fn isset(&self, key: &str) -> bool { pub fn isset(&self, key: &str) -> bool {
self.store.get(key).is_some() self.store.contains_key(key)
} }
// -- setters // -- setters