mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-13 21:52:37 +00:00
refactor: minimize visibility of functions
This commit is contained in:
parent
08626b84fc
commit
0a7e6e7f47
5 changed files with 11 additions and 11 deletions
|
@ -67,11 +67,11 @@ pub enum Elem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Elem {
|
impl Elem {
|
||||||
pub fn has_suid(&self) -> bool {
|
fn has_suid(&self) -> bool {
|
||||||
matches!(self, Elem::Dir { uid: true } | Elem::File { uid: true, .. })
|
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 {
|
match self {
|
||||||
Elem::File {
|
Elem::File {
|
||||||
exec: true,
|
exec: true,
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl Date {
|
||||||
colors.colorize(self.date_string(flags), &elem)
|
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 {
|
if let Date::Date(val) = self {
|
||||||
match &flags.date {
|
match &flags.date {
|
||||||
DateFlag::Date => val.format("%c").to_string(),
|
DateFlag::Date => val.format("%c").to_string(),
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl Name {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn escape(&self, string: &str) -> String {
|
fn escape(&self, string: &str) -> String {
|
||||||
if string
|
if string
|
||||||
.chars()
|
.chars()
|
||||||
.all(|c| c >= 0x20 as char && c != 0x7f as char)
|
.all(|c| c >= 0x20 as char && c != 0x7f as char)
|
||||||
|
|
|
@ -169,7 +169,7 @@ mod test {
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn permission_rwx() {
|
fn permission_rwx() {
|
||||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||||
|
|
||||||
// Create the file;
|
// Create the file;
|
||||||
|
@ -189,7 +189,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn permission_rwx2() {
|
fn permission_rwx2() {
|
||||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||||
|
|
||||||
// Create the file;
|
// Create the file;
|
||||||
|
@ -209,7 +209,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn permission_rwx_sticky() {
|
fn permission_rwx_sticky() {
|
||||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||||
|
|
||||||
// Create the file;
|
// Create the file;
|
||||||
|
@ -231,7 +231,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn permission_octal() {
|
fn permission_octal() {
|
||||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||||
|
|
||||||
// Create the file;
|
// Create the file;
|
||||||
|
@ -252,7 +252,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn permission_octal2() {
|
fn permission_octal2() {
|
||||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||||
|
|
||||||
// Create the file;
|
// Create the file;
|
||||||
|
@ -273,7 +273,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn permission_octal_sticky() {
|
fn permission_octal_sticky() {
|
||||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||||
|
|
||||||
// Create the file;
|
// Create the file;
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl Size {
|
||||||
format!("{0:.1$}", number, if number < 10.0 { 1 } else { 0 })
|
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 {
|
if flags.size == SizeFlag::Bytes {
|
||||||
return Unit::Byte;
|
return Unit::Byte;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue