소스 검색

Start using new shorthand object field syntax

Benjamin Sago 8 년 전
부모
커밋
2f79b4db03
6개의 변경된 파일17개의 추가작업 그리고 49개의 파일을 삭제
  1. 2 4
      src/exa.rs
  2. 1 4
      src/options/dir_action.rs
  3. 1 5
      src/options/mod.rs
  4. 9 19
      src/options/view.rs
  5. 1 8
      src/output/details.rs
  6. 3 9
      src/output/file_name.rs

+ 2 - 4
src/exa.rs

@@ -55,10 +55,8 @@ pub struct Exa<'w, W: Write + 'w> {
 impl<'w, W: Write + 'w> Exa<'w, W> {
     pub fn new<S>(args: &[S], writer: &'w mut W) -> Result<Exa<'w, W>, Misfire>
     where S: AsRef<OsStr> {
-        Options::getopts(args).map(move |(opts, args)| Exa {
-            options: opts,
-            writer:  writer,
-            args:    args,
+        Options::getopts(args).map(move |(options, args)| {
+            Exa { options, writer, args }
         })
     }
 

+ 1 - 4
src/options/dir_action.rs

@@ -89,10 +89,7 @@ impl RecurseOptions {
             None
         };
 
-        Ok(RecurseOptions {
-            tree: tree,
-            max_depth: max_depth,
-        })
+        Ok(RecurseOptions { tree, max_depth })
     }
 
     /// Returns whether a directory of the given depth would be too deep.

+ 1 - 5
src/options/mod.rs

@@ -143,11 +143,7 @@ impl Options {
         let filter = FileFilter::deduce(matches)?;
         let view = View::deduce(matches, filter.clone(), dir_action)?;
 
-        Ok(Options {
-            dir_action: dir_action,
-            view:       view,
-            filter:     filter,  // TODO: clone
-        })
+        Ok(Options { dir_action, view, filter })
     }
 }
 

+ 9 - 19
src/options/view.rs

@@ -94,9 +94,9 @@ impl View {
 
             if let Some(&width) = term_width.as_ref() {
                 let colours = match term_colours {
-                    TerminalColours::Always
-                    | TerminalColours::Automatic => Colours::colourful(colour_scale()),
-                    TerminalColours::Never     => Colours::plain(),
+                    TerminalColours::Always     |
+                    TerminalColours::Automatic  => Colours::colourful(colour_scale()),
+                    TerminalColours::Never      => Colours::plain(),
                 };
 
                 if matches.opt_present("oneline") {
@@ -104,12 +104,7 @@ impl View {
                         Err(Useless("across", true, "oneline"))
                     }
                     else {
-                        let lines = Lines {
-                             colours: colours,
-                             classify: classify,
-                        };
-
-                        Ok(View::Lines(lines))
+                        Ok(View::Lines(Lines { colours, classify }))
                     }
                 }
                 else if matches.opt_present("tree") {
@@ -160,28 +155,23 @@ impl View {
                     Ok(View::Details(details))
                 }
                 else {
-                    let lines = Lines {
-                         colours: colours,
-                         classify: classify,
-                    };
-
-                    Ok(View::Lines(lines))
+                    Ok(View::Lines(Lines { colours, classify }))
                 }
             }
         };
 
         if matches.opt_present("long") {
-            let long_options = long()?;
+            let details = long()?;
 
             if matches.opt_present("grid") {
                 match other_options_scan() {
-                    Ok(View::Grid(grid)) => return Ok(View::GridDetails(GridDetails { grid: grid, details: long_options })),
+                    Ok(View::Grid(grid)) => return Ok(View::GridDetails(GridDetails { grid, details })),
                     Ok(lines)            => return Ok(lines),
                     Err(e)               => return Err(e),
                 };
             }
             else {
-                return Ok(View::Details(long_options));
+                return Ok(View::Details(details));
             }
         }
 
@@ -313,7 +303,7 @@ impl TimeTypes {
             }
         }
         else if modified || created || accessed {
-            Ok(TimeTypes { accessed: accessed, modified: modified, created: created })
+            Ok(TimeTypes { accessed, modified, created })
         }
         else {
             Ok(TimeTypes::default())

+ 1 - 8
src/output/details.rs

@@ -316,14 +316,7 @@ impl Details {
                         }
                     };
 
-                    let egg = Egg {
-                        cells: cells,
-                        xattrs: xattrs,
-                        errors: errors,
-                        dir: dir,
-                        file: file,
-                    };
-
+                    let egg = Egg { cells, xattrs, errors, dir, file };
                     file_eggs.lock().unwrap().push(egg);
                 });
             }

+ 3 - 9
src/output/file_name.rs

@@ -34,15 +34,9 @@ impl<'a, 'dir> FileName<'a, 'dir> {
     /// Create a new `FileName` that prints the given file’s name, painting it
     /// with the remaining arguments.
     pub fn new(file: &'a File<'dir>, link_style: LinkStyle, classify: Classify, colours: &'a Colours) -> FileName<'a, 'dir> {
-        let target =  if file.is_link() { Some(file.link_target()) }
-                                                       else { None };
-        FileName {
-            file: file,
-            colours: colours,
-            target: target,
-            link_style: link_style,
-            classify: classify,
-        }
+        let target = if file.is_link() { Some(file.link_target()) }
+                                                      else { None };
+        FileName { file, colours, target, link_style, classify }
     }