about summary refs log tree commit diff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <mail@marcusklaas.nl>2015-08-19 21:53:02 +0200
committerMarcus Klaas de Vries <mail@marcusklaas.nl>2015-08-19 21:53:02 +0200
commit8dbe2133fb342c0db21a583d10c2882a42f2e869 (patch)
tree2083708c88a4efb64ac462f03b29fc687a704c6d /src/utils.rs
parent2ef0b179558f85a0a0288d8fa1500732cd2512d5 (diff)
parent8e22a73cb73db27e4d4e30b263839164c97efcd6 (diff)
Merge pull request #178 from marcusklaas/single-config-override
Allow override of single configuration lines in 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"),
+                }
+            }
+        }
     };
 }