Merge pull request #108 from Txreq/escapeuse

Add token escaping for Rust output `r#use`
This commit is contained in:
a2x
2024-04-05 00:43:39 +10:00
committed by GitHub

View File

@@ -78,11 +78,12 @@ impl CodeGen for Vec<Button> {
fmt.block("pub mod buttons", false, |fmt| { fmt.block("pub mod buttons", false, |fmt| {
for button in self { for button in self {
writeln!( let mut name = button.name.clone();
fmt, if name == "use" {
"pub const {}: usize = {:#X};", name = format!("r#{}", name);
button.name, button.value }
)?;
writeln!(fmt, "pub const {}: usize = {:#X};", name, button.value)?;
} }
Ok(()) Ok(())