This commit is contained in:
Steven Fackler
2016-02-21 20:02:34 -08:00
parent 2ed1367a3b
commit 15fe3f7c5f
6 changed files with 29 additions and 36 deletions

View File

@@ -96,14 +96,16 @@ pub enum SqlState {{
write!(file,
" /// An unknown code
Other(String)
Other(String),
}}
"
).unwrap();
}
fn make_map(codes: &[Code], file: &mut BufWriter<File>) {
write!(file, "static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ").unwrap();
write!(file,
"#[cfg_attr(rustfmt, rustfmt_skip)]
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ").unwrap();
let mut builder = phf_codegen::Map::new();
for code in codes {
builder.entry(&*code.code, &format!("SqlState::{}", code.variant));
@@ -119,7 +121,7 @@ impl SqlState {{
pub fn from_code(s: String) -> SqlState {{
match SQLSTATE_MAP.get(&*s) {{
Some(state) => state.clone(),
None => SqlState::Other(s)
None => SqlState::Other(s),
}}
}}