From 0a7e6e7f4785c4681711a9ea621ce780c75c3b0c Mon Sep 17 00:00:00 2001 From: Narawit Rakket Date: Fri, 12 Aug 2022 22:47:26 +0700 Subject: [PATCH] refactor: minimize visibility of functions --- src/color.rs | 4 ++-- src/meta/date.rs | 2 +- src/meta/name.rs | 2 +- src/meta/permissions.rs | 12 ++++++------ src/meta/size.rs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/color.rs b/src/color.rs index e401708..c3bd938 100644 --- a/src/color.rs +++ b/src/color.rs @@ -67,11 +67,11 @@ pub enum Elem { } impl Elem { - pub fn has_suid(&self) -> bool { + fn has_suid(&self) -> bool { matches!(self, Elem::Dir { uid: true } | Elem::File { uid: true, .. }) } - pub fn get_color(&self, theme: &theme::Theme) -> Color { + fn get_color(&self, theme: &theme::Theme) -> Color { match self { Elem::File { exec: true, diff --git a/src/meta/date.rs b/src/meta/date.rs index 4dd9a76..b6f447c 100644 --- a/src/meta/date.rs +++ b/src/meta/date.rs @@ -41,7 +41,7 @@ impl Date { colors.colorize(self.date_string(flags), &elem) } - pub fn date_string(&self, flags: &Flags) -> String { + fn date_string(&self, flags: &Flags) -> String { if let Date::Date(val) = self { match &flags.date { DateFlag::Date => val.format("%c").to_string(), diff --git a/src/meta/name.rs b/src/meta/name.rs index 4d5052b..8bfa5d5 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -78,7 +78,7 @@ impl Name { .collect() } - pub fn escape(&self, string: &str) -> String { + fn escape(&self, string: &str) -> String { if string .chars() .all(|c| c >= 0x20 as char && c != 0x7f as char) diff --git a/src/meta/permissions.rs b/src/meta/permissions.rs index ef6272a..79a0e47 100644 --- a/src/meta/permissions.rs +++ b/src/meta/permissions.rs @@ -169,7 +169,7 @@ mod test { use tempfile::tempdir; #[test] - pub fn permission_rwx() { + fn permission_rwx() { let tmp_dir = tempdir().expect("failed to create temp dir"); // Create the file; @@ -189,7 +189,7 @@ mod test { } #[test] - pub fn permission_rwx2() { + fn permission_rwx2() { let tmp_dir = tempdir().expect("failed to create temp dir"); // Create the file; @@ -209,7 +209,7 @@ mod test { } #[test] - pub fn permission_rwx_sticky() { + fn permission_rwx_sticky() { let tmp_dir = tempdir().expect("failed to create temp dir"); // Create the file; @@ -231,7 +231,7 @@ mod test { } #[test] - pub fn permission_octal() { + fn permission_octal() { let tmp_dir = tempdir().expect("failed to create temp dir"); // Create the file; @@ -252,7 +252,7 @@ mod test { } #[test] - pub fn permission_octal2() { + fn permission_octal2() { let tmp_dir = tempdir().expect("failed to create temp dir"); // Create the file; @@ -273,7 +273,7 @@ mod test { } #[test] - pub fn permission_octal_sticky() { + fn permission_octal_sticky() { let tmp_dir = tempdir().expect("failed to create temp dir"); // Create the file; diff --git a/src/meta/size.rs b/src/meta/size.rs index f572580..9f39b99 100644 --- a/src/meta/size.rs +++ b/src/meta/size.rs @@ -40,7 +40,7 @@ impl Size { format!("{0:.1$}", number, if number < 10.0 { 1 } else { 0 }) } - pub fn get_unit(&self, flags: &Flags) -> Unit { + fn get_unit(&self, flags: &Flags) -> Unit { if flags.size == SizeFlag::Bytes { return Unit::Byte; }