Start using new shorthand object field syntax

This commit is contained in:
Benjamin Sago 2017-05-18 22:43:32 +01:00
parent 881438881f
commit 2f79b4db03
6 changed files with 17 additions and 49 deletions

View File

@ -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 }
})
}

View File

@ -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.

View File

@ -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 })
}
}

View File

@ -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())

View File

@ -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);
});
}

View File

@ -34,15 +34,9 @@ impl<'a, 'dir> FileName<'a, 'dir> {
/// Create a new `FileName` that prints the given files 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 }
}