From 89a2ef5e9c7cbfde245bd6dbc932ed576c0c497e Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:36:46 +0700 Subject: [PATCH] Fix clippy::enum_variant_names --- file/file.rs | 1 + tree/ls.rs | 19 ++++++++++--------- tree/ls_util/entry.rs | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/file/file.rs b/file/file.rs index 7280314a..f79016ec 100644 --- a/file/file.rs +++ b/file/file.rs @@ -70,6 +70,7 @@ struct Args { } /// Errors that can occur during parsing of a raw magic line. +#[allow(clippy::enum_variant_names)] #[derive(Debug)] enum RawMagicLineParseError { /// Indicates that the offset format is invalid. diff --git a/tree/ls.rs b/tree/ls.rs index a43a1846..cd260341 100644 --- a/tree/ls.rs +++ b/tree/ls.rs @@ -296,9 +296,9 @@ struct LongFormatOptions { enum OutputFormat { MultiColumn, MultiColumnAcross, - StreamOutputFormat, + Stream, OneEntryPerLine, - LongFormat(LongFormatOptions), + Long(LongFormatOptions), } enum SortBy { @@ -320,6 +320,7 @@ enum DereferenceSymbolicLink { None, } +#[allow(clippy::enum_variant_names)] enum FileTimeOption { LastModificationTime, LastStatusChangeTime, @@ -451,7 +452,7 @@ impl Config { ) { (false, false, false, false) => { if long_format_enabled { - OutputFormat::LongFormat(long_format_options) + OutputFormat::Long(long_format_options) } else { // According to the specification: // @@ -464,7 +465,7 @@ impl Config { } } (true, false, false, false) => OutputFormat::MultiColumn, - (false, true, false, false) => OutputFormat::StreamOutputFormat, + (false, true, false, false) => OutputFormat::Stream, (false, false, true, false) => OutputFormat::MultiColumnAcross, (false, false, false, true) => OutputFormat::OneEntryPerLine, _ => unreachable!(), // -C, -m, -x, and -1 are mutually exclusive @@ -718,7 +719,7 @@ fn display_entries(entries: &mut [Entry], config: &Config, dir_path: Option<&str } let mut display_total_size = config.display_size; - if let OutputFormat::LongFormat(_) = &config.output_format { + if let OutputFormat::Long(_) = &config.output_format { display_total_size = true; } @@ -743,7 +744,7 @@ fn display_entries(entries: &mut [Entry], config: &Config, dir_path: Option<&str } match &config.output_format { - OutputFormat::LongFormat(_) => { + OutputFormat::Long(_) => { let mut padding = LongFormatPadding::default(); // Calculate required padding @@ -829,7 +830,7 @@ fn display_entries(entries: &mut [Entry], config: &Config, dir_path: Option<&str println!(); } } - OutputFormat::StreamOutputFormat => { + OutputFormat::Stream => { let stream_outputs: Vec<_> = entries .iter() .map(|entry| entry.build_stream_mode_string()) @@ -962,7 +963,7 @@ fn ls(paths: Vec, config: &Config) -> io::Result { let target_path = { let mut target_path = None; if metadata.is_symlink() && !dereference_symlink { - if let OutputFormat::LongFormat(_) = &config.output_format { + if let OutputFormat::Long(_) = &config.output_format { let mut buf = vec![0u8; libc::PATH_MAX as usize]; let path_cstr = CString::new(path.as_os_str().as_bytes()).unwrap(); @@ -1174,7 +1175,7 @@ fn process_single_dir( let mut target_path = None; if metadata.is_symlink() && !dereference_symlink { - if let OutputFormat::LongFormat(_) = &config.output_format { + if let OutputFormat::Long(_) = &config.output_format { target_path = Some(ls_from_utf8_lossy( dir_entry.read_link().unwrap().to_bytes(), )); diff --git a/tree/ls_util/entry.rs b/tree/ls_util/entry.rs index b3816c48..b97d6c36 100644 --- a/tree/ls_util/entry.rs +++ b/tree/ls_util/entry.rs @@ -80,7 +80,7 @@ impl Entry { }; let long_format_data = - if let OutputFormat::LongFormat(long_format_options) = &config.output_format { + if let OutputFormat::Long(long_format_options) = &config.output_format { Some(LongFormatData::new(metadata, long_format_options)?) } else { None