Add token escaping for Rust output `r#use`

This commit is contained in:
Txreq 2024-04-04 07:38:06 +02:00
parent 3a935f5d73
commit c75480be3e
1 changed files with 6 additions and 5 deletions

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(())