From 8d681b36fab0a1a32903ef1711fc4e0ca23e8026 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 11 Feb 2016 19:56:44 -0800 Subject: [PATCH] Derive debug for SqlState The code generation problems that required the manual impl are now gone. --- build.rs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/build.rs b/build.rs index 62e3e917..d6081e3f 100644 --- a/build.rs +++ b/build.rs @@ -493,7 +493,6 @@ fn main() { make_enum(&codes, &mut file); make_map(&codes, &mut file); make_impl(&codes, &mut file); - make_debug(&codes, &mut file); // This is already assumed to be the case but there's no way to say that // you don't depend on anything at all @@ -571,7 +570,7 @@ fn variant_name(code: &str) -> Option { fn make_enum(codes: &[Code], file: &mut BufWriter) { write!(file, r#"/// SQLSTATE error codes -#[derive(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone, Debug)] pub enum SqlState {{ "# ).unwrap(); @@ -631,26 +630,3 @@ impl SqlState {{ "# ).unwrap(); } - -fn make_debug(codes: &[Code], file: &mut BufWriter) { - write!(file, r#" -impl fmt::Debug for SqlState {{ - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {{ - let s = match *self {{"# - ).unwrap(); - - for code in codes { - write!(file, r#" - SqlState::{0} => "{0}","#, - code.variant).unwrap(); - } - - write!(file, r#" - SqlState::Other(ref s) => return write!(fmt, "Other({{:?}})", s), - }}; - fmt.write_str(s) - }} -}} -"# - ).unwrap(); -}