Просмотр исходного кода

Collapse down similar branches of match-statement

Daniel Lockyer 9 лет назад
Родитель
Сommit
ec84f16da7
2 измененных файлов с 11 добавлено и 12 удалено
  1. 6 7
      src/options/view.rs
  2. 5 5
      src/output/column.rs

+ 6 - 7
src/options/view.rs

@@ -91,9 +91,9 @@ impl View {
 
             if let Some(&width) = term_width.as_ref() {
                 let colours = match term_colours {
-                    TerminalColours::Always    => Colours::colourful(colour_scale()),
+                    TerminalColours::Always
+                    | TerminalColours::Automatic => Colours::colourful(colour_scale()),
                     TerminalColours::Never     => Colours::plain(),
-                    TerminalColours::Automatic => Colours::colourful(colour_scale()),
                 };
 
                 if matches.opt_present("oneline") {
@@ -137,8 +137,7 @@ impl View {
 
                 let colours = match term_colours {
                     TerminalColours::Always    => Colours::colourful(colour_scale()),
-                    TerminalColours::Never     => Colours::plain(),
-                    TerminalColours::Automatic => Colours::plain(),
+                    TerminalColours::Never | TerminalColours::Automatic => Colours::plain(),
                 };
 
                 if matches.opt_present("tree") {
@@ -221,9 +220,9 @@ impl TerminalWidth {
 
     fn as_ref(&self) -> Option<&usize> {
         match *self {
-            TerminalWidth::Set(ref width)       => Some(width),
-            TerminalWidth::Terminal(ref width)  => Some(width),
-            TerminalWidth::Unset                => None,
+            TerminalWidth::Set(ref width)
+            | TerminalWidth::Terminal(ref width)    => Some(width),
+            TerminalWidth::Unset                    => None,
         }
     }
 }

+ 5 - 5
src/output/column.rs

@@ -27,11 +27,11 @@ impl Column {
     /// Get the alignment this column should use.
     pub fn alignment(&self) -> Alignment {
         match *self {
-            Column::FileSize(_) => Alignment::Right,
-            Column::HardLinks   => Alignment::Right,
-            Column::Inode       => Alignment::Right,
-            Column::Blocks      => Alignment::Right,
-            Column::GitStatus   => Alignment::Right,
+            Column::FileSize(_)
+            | Column::HardLinks
+            | Column::Inode
+            | Column::Blocks
+            | Column::GitStatus => Alignment::Right,
             _                   => Alignment::Left,
         }
     }