summaryrefslogtreecommitdiffstats
path: root/src/value.rs
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2017-01-26 00:09:41 -0800
committerRyan Leckey <leckey.ryan@gmail.com>2017-01-26 00:09:41 -0800
commita6fb2f92dc8d53660c1d2d066f146ef261052330 (patch)
treed66d90b8e563f0df6bee8563847ba9e67edfa9b7 /src/value.rs
parent7c696e6b457debb0faca4fdb0d55e3ed43773484 (diff)
Add some examples
Diffstat (limited to 'src/value.rs')
-rw-r--r--src/value.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/value.rs b/src/value.rs
index 192632b..52a2103 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -5,7 +5,7 @@ use std::borrow::Cow;
///
/// Has an underlying or native type that comes from the configuration source
/// but will be coerced into the requested type.
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum Value {
String(String),
Integer(i64),
@@ -35,10 +35,11 @@ impl Value {
if let Value::Boolean(value) = *self {
Some(value)
} else if let Value::String(ref value) = *self {
- Some(match value.to_lowercase().as_ref() {
- "1" | "true" | "on" | "yes" => true,
- _ => false,
- })
+ match value.to_lowercase().as_ref() {
+ "1" | "true" | "on" | "yes" => Some(true),
+ "0" | "false" | "off" | "no" => Some(false),
+ _ => None,
+ }
} else if let Value::Integer(value) = *self {
Some(value != 0)
} else if let Value::Float(value) = *self {