diff --git a/src/codegen/branchify.rs b/src/codegen/branchify.rs index b33c5544..f8b50ce4 100644 --- a/src/codegen/branchify.rs +++ b/src/codegen/branchify.rs @@ -110,7 +110,7 @@ pub fn generate_branchified_method( end: &str, max_len: &str, valid: &str, unknown: &str) { for &c in branch.matches.iter() { let next_prefix = format!("{}{}", prefix, c as char); - wf!("Some(b) if b == '{}' as u8 => match {} \\{", c as char, read_call); + wf!("Some(b) if b == '{}' as u8 => match {} {{", c as char, read_call); for b in branch.children.iter() { r(writer, b, next_prefix.as_slice(), indent + 1, read_call, end, max_len, valid, unknown); } @@ -121,30 +121,30 @@ pub fn generate_branchified_method( } wf!(" Some(b) if {} => (\"{}\", b),", valid, next_prefix.as_slice()); wf!(" _ => return None,"); - wf!("\\},"); + wf!("}},"); } } - wf!("let (s, next_byte) = match {} \\{", read_call); + wf!("let (s, next_byte) = match {} {{", read_call); for b in branches.iter() { r(writer, b, "", indent + 1, read_call, end, max_len, valid, unknown); } wf!(" Some(b) if {} => (\"\", b),", valid); wf!(" _ => return None,"); - wf!("\\};"); + wf!("}};"); wf!("// OK, that didn't pan out. Let's read the rest and see what we get."); wf!("let mut s = s.to_string();"); wf!("s.push_char(next_byte as char);"); - wf!("loop \\{"); - wf!(" match {} \\{", read_call); + wf!("loop {{"); + wf!(" match {} {{", read_call); wf!(" Some(b) if b == {} => return Some({}),", end, unknown.replace("{}", "s")); - wf!(" Some(b) if {} => \\{", valid); - wf!(" if s.len() == {} \\{", max_len); + wf!(" Some(b) if {} => {{", valid); + wf!(" if s.len() == {} {{", max_len); wf!(" // Too long; bad request"); wf!(" return None;"); - wf!(" \\}"); + wf!(" }}"); wf!(" s.push_char(b as char);"); - wf!(" \\},"); + wf!(" }},"); wf!(" _ => return None,"); - wf!(" \\}"); - wf!("\\}"); + wf!(" }}"); + wf!("}}"); } diff --git a/src/codegen/keycode.rs b/src/codegen/keycode.rs index 3a6e7215..103901ab 100644 --- a/src/codegen/keycode.rs +++ b/src/codegen/keycode.rs @@ -345,9 +345,9 @@ impl ToPrimitive for KeyCode { ".as_bytes())); let types = vec!("i64", "u64", "int"); for primitive_type in types.iter() { - try!(out.write(format!("fn to_{}(&self) -> Option<{}> \\{ + try!(out.write(format!("fn to_{}(&self) -> Option<{}> {{ Some(self.code() as {}) - \\}\n", *primitive_type, *primitive_type, *primitive_type).container_as_bytes())); + }}\n", *primitive_type, *primitive_type, *primitive_type).container_as_bytes())); } try!(out.write(" @@ -363,8 +363,8 @@ impl FromPrimitive for KeyCode { ".as_bytes())); for primitive_type in types.iter() { try!(out.write(format!(" - fn from_{}(n: {}) -> Option \\{ - match n \\{ + fn from_{}(n: {}) -> Option {{ + match n {{ ", *primitive_type, *primitive_type).container_as_bytes())); for &entry in entries.iter() { try!(out.write(format!(" {} => Some({}),\n", entry.code, entry.ident()).container_as_bytes())); diff --git a/src/codegen/scancode.rs b/src/codegen/scancode.rs index 4dd3dfa0..f095db75 100644 --- a/src/codegen/scancode.rs +++ b/src/codegen/scancode.rs @@ -355,9 +355,9 @@ impl ToPrimitive for ScanCode { let types = vec!("i64", "u64", "int"); for primitive_type in types.iter() { - try!(out.write(format!("fn to_{}(&self) -> Option<{}> \\{ + try!(out.write(format!("fn to_{}(&self) -> Option<{}> {{ Some(self.code() as {}) - \\}\n", *primitive_type, *primitive_type, *primitive_type).container_as_bytes())); + }}\n", *primitive_type, *primitive_type, *primitive_type).container_as_bytes())); } try!(out.write(" @@ -374,8 +374,8 @@ impl FromPrimitive for ScanCode { for primitive_type in types.iter() { try!(out.write(format!(" - fn from_{}(n: {}) -> Option \\{ - match n \\{ + fn from_{}(n: {}) -> Option {{ + match n {{ ", *primitive_type, *primitive_type).container_as_bytes())); for &entry in entries.iter() {