Browse Source

refactoring: remove unnecessary return statements

main
fdai7381 2 years ago
committed by fdai7451
parent
commit
2c242c9551
  1. 12
      src/builtins/ls.rs

12
src/builtins/ls.rs

@ -56,11 +56,11 @@ impl Builtin for Ls {
fn format_filesize(filesize: u64) -> String { fn format_filesize(filesize: u64) -> String {
if filesize > 9_999 && filesize <= 999_999 { if filesize > 9_999 && filesize <= 999_999 {
return format!("{}KB", filesize / 1_000);
format!("{}KB", filesize / 1_000)
} else if filesize > 999_999 && filesize <= 999_999_999 { } else if filesize > 999_999 && filesize <= 999_999_999 {
return format!("{}MB", filesize / 1_000_000);
format!("{}MB", filesize / 1_000_000)
} else if filesize > 999_999_999 { } else if filesize > 999_999_999 {
return format!("{}MB", filesize / 1_000_000_000);
format!("{}MB", filesize / 1_000_000_000)
} else { } else {
format!("{}B", filesize) format!("{}B", filesize)
} }
@ -69,14 +69,14 @@ fn format_filesize(filesize: u64) -> String {
fn format_date(date: DateTime<Local>) -> String { fn format_date(date: DateTime<Local>) -> String {
let now: DateTime<Local> = Local::now(); let now: DateTime<Local> = Local::now();
if date.day() != now.day() || date.month() != now.month() || date.year() != now.year() { if date.day() != now.day() || date.month() != now.month() || date.year() != now.year() {
return format!("{}-{:02}-{:02}", date.year(), date.month(), date.day());
format!("{}-{:02}-{:02}", date.year(), date.month(), date.day())
} else { } else {
return format!(
format!(
"{:02}:{:02}:{:02}", "{:02}:{:02}:{:02}",
date.hour(), date.hour(),
date.minute(), date.minute(),
date.second() date.second()
);
)
} }
} }

Loading…
Cancel
Save