summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Sago <ogham@bsago.me>2016-04-16 22:25:24 +0100
committerBenjamin Sago <ogham@bsago.me>2016-04-16 22:25:24 +0100
commitb44ae1b56b3e0f83c5ab314b96b221274b3c5d3c (patch)
tree5bb86fee145a52fbaa7fba522b0df6a6fad1ff2b
parent45c93b1b63f2ee17ea15448c048f16dc9a646706 (diff)
Remove pointless OptionSet trait
The trait was only used internally to the options module, so it doesn't actually need to be exist or implemented on anything! We can just impl them directly on the types and have those methods be local to the module.
-rw-r--r--src/options.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/options.rs b/src/options.rs
index 7add419..d794387 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -124,9 +124,7 @@ impl Options {
_ => false,
}
}
-}
-impl OptionSet for Options {
fn deduce(matches: &getopts::Matches) -> Result<Options, Misfire> {
let dir_action = try!(DirAction::deduce(&matches));
let filter = try!(FileFilter::deduce(&matches));
@@ -309,11 +307,6 @@ impl View {
}
-trait OptionSet: Sized {
- fn deduce(matches: &getopts::Matches) -> Result<Self, Misfire>;
-}
-
-
/// The **file filter** processes a vector of files before outputting them,
/// filtering and sorting the files depending on the user’s command-line
/// flags.
@@ -325,7 +318,7 @@ pub struct FileFilter {
sort_field: SortField,
}
-impl OptionSet for FileFilter {
+impl FileFilter {
fn deduce(matches: &getopts::Matches) -> Result<FileFilter, Misfire> {
let sort_field = try!(SortField::deduce(&matches));
@@ -336,9 +329,6 @@ impl OptionSet for FileFilter {
sort_field: sort_field,
})
}
-}
-
-impl FileFilter {
/// Remove every file in the given vector that does *not* pass the
/// filter predicate.
@@ -493,7 +483,7 @@ impl Default for SortField {
}
}
-impl OptionSet for SortField {
+impl SortField {
fn deduce(matches: &getopts::Matches) -> Result<SortField, Misfire> {
if let Some(word) = matches.opt_str("sort") {
match &*word {
@@ -523,7 +513,7 @@ enum TerminalWidth {
Unset,
}
-impl OptionSet for TerminalWidth {
+impl TerminalWidth {
fn deduce(_: &getopts::Matches) -> Result<TerminalWidth, Misfire> {
if let Some(columns) = var_os("COLUMNS").and_then(|s| s.into_string().ok()) {
match columns.parse() {
@@ -554,7 +544,7 @@ impl Default for TerminalColours {
}
}
-impl OptionSet for TerminalColours {
+impl TerminalColours {
fn deduce(matches: &getopts::Matches) -> Result<TerminalColours, Misfire> {
if let Some(word) = matches.opt_str("color").or(matches.opt_str("colour")) {
match &*word {
@@ -571,7 +561,7 @@ impl OptionSet for TerminalColours {
}
-impl OptionSet for Columns {
+impl Columns {
fn deduce(matches: &getopts::Matches) -> Result<Columns, Misfire> {
Ok(Columns {
size_format: try!(SizeFormat::deduce(matches)),
@@ -586,7 +576,7 @@ impl OptionSet for Columns {
}
-impl OptionSet for SizeFormat {
+impl SizeFormat {
/// Determine which file size to use in the file size column based on
/// the user’s options.
@@ -610,7 +600,7 @@ impl OptionSet for SizeFormat {
}
-impl OptionSet for TimeTypes {
+impl TimeTypes {
/// Determine which of a file’s time fields should be displayed for it
/// based on the user’s options.