summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2015-05-16 18:33:24 +0100
committerBen S <ogham@bsago.me>2015-05-16 18:34:05 +0100
commit8e7efed3f5ca66b0a92d13865f01d003bdadd918 (patch)
treec422cc7799d980ba1662a4276441f1c8cc15d9b6 /src/options.rs
parent5ffff841e00583061d4dbf485119c00df9289ec3 (diff)
Add Default instances in Options
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/options.rs b/src/options.rs
index dd5ec52..9d8471d 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -343,6 +343,12 @@ pub enum SizeFormat {
JustBytes,
}
+impl Default for SizeFormat {
+ fn default() -> SizeFormat {
+ SizeFormat::DecimalBytes
+ }
+}
+
impl SizeFormat {
pub fn deduce(matches: &getopts::Matches) -> Result<SizeFormat, Misfire> {
let binary = matches.opt_present("binary");
@@ -381,6 +387,12 @@ pub struct TimeTypes {
created: bool,
}
+impl Default for TimeTypes {
+ fn default() -> TimeTypes {
+ TimeTypes { accessed: false, modified: true, created: false }
+ }
+}
+
impl TimeTypes {
/// Find which field to use based on a user-supplied word.
@@ -413,7 +425,7 @@ impl TimeTypes {
Ok(TimeTypes { accessed: accessed, modified: modified, created: created })
}
else {
- Ok(TimeTypes { accessed: false, modified: true, created: false })
+ Ok(TimeTypes::default())
}
}
}
@@ -504,7 +516,7 @@ impl RecurseOptions {
}
}
-#[derive(PartialEq, Copy, Clone, Debug)]
+#[derive(PartialEq, Copy, Clone, Debug, Default)]
pub struct Columns {
size_format: SizeFormat,
time_types: TimeTypes,