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
commit efe4775dc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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| {
for button in self {
writeln!(
fmt,
"pub const {}: usize = {:#X};",
button.name, button.value
)?;
let mut name = button.name.clone();
if name == "use" {
name = format!("r#{}", name);
}
writeln!(fmt, "pub const {}: usize = {:#X};", name, button.value)?;
}
Ok(())