diff options
Diffstat (limited to 'src/fs/entry.rs')
-rw-r--r-- | src/fs/entry.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fs/entry.rs b/src/fs/entry.rs index a4e2672..4cf3ead 100644 --- a/src/fs/entry.rs +++ b/src/fs/entry.rs @@ -61,3 +61,34 @@ impl JoshutoDirEntry { self.selected = selected; } } + +impl std::fmt::Display for JoshutoDirEntry { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + write!(f, "{}", self.file_name()) + } +} + +impl std::convert::AsRef<str> for JoshutoDirEntry { + fn as_ref(&self) -> &str { + self.file_name() + } +} + +impl std::cmp::PartialEq for JoshutoDirEntry { + fn eq(&self, other: &Self) -> bool { + self.file_path() == other.file_path() + } +} +impl std::cmp::Eq for JoshutoDirEntry {} + +impl std::cmp::PartialOrd for JoshutoDirEntry { + fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { + Some(self.cmp(other)) + } +} + +impl std::cmp::Ord for JoshutoDirEntry { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.file_path().cmp(other.file_path()) + } +} |