about summary refs log tree commit diff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorMarcus Klaas <mail@marcusklaas.nl>2015-08-19 21:41:19 +0200
committerMarcus Klaas <mail@marcusklaas.nl>2015-08-19 21:51:03 +0200
commit8e22a73cb73db27e4d4e30b263839164c97efcd6 (patch)
tree2083708c88a4efb64ac462f03b29fc687a704c6d /src/utils.rs
parent2ef0b179558f85a0a0288d8fa1500732cd2512d5 (diff)
Add option to override single configuration lines for tests
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 59f85b3ad27..a57ffb008ea 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -144,6 +144,19 @@ macro_rules! impl_enum_decodable {
                 }
             }
         }
+
+        impl ::std::str::FromStr for $e {
+            type Err = &'static str;
+
+            fn from_str(s: &str) -> Result<Self, Self::Err> {
+                match &*s {
+                    $(
+                        stringify!($x) => Ok($e::$x),
+                    )*
+                    _ => Err("Bad variant"),
+                }
+            }
+        }
     };
 }