bindgen: everything works

This commit is contained in:
nym21
2026-03-16 11:37:53 +01:00
parent d3721b0020
commit b74319bf10
21 changed files with 189 additions and 96 deletions
@@ -92,8 +92,7 @@ impl LanguageSyntax for JavaScriptSyntax {
// "ratio_{disc}_bps" → split on {disc} → _m(_m(acc, 'ratio'), disc) then _bps
// But this is complex. For embedded disc, use string interpolation.
// For suffix disc (ends with {disc}), use _m composition.
if template.ends_with("{disc}") {
let static_part = &template[..template.len() - "{disc}".len()];
if let Some(static_part) = template.strip_suffix("{disc}") {
if static_part.is_empty() {
format!("_m({}, disc)", var_name)
} else {
+2 -2
View File
@@ -1,6 +1,6 @@
//! Rust language syntax implementation.
use crate::{GenericSyntax, LanguageSyntax, to_snake_case};
use crate::{GenericSyntax, LanguageSyntax, escape_rust_keyword, to_snake_case};
/// Rust-specific code generation syntax.
pub struct RustSyntax;
@@ -15,7 +15,7 @@ fn escape_rust_format(template: &str) -> String {
impl LanguageSyntax for RustSyntax {
fn field_name(&self, name: &str) -> String {
to_snake_case(name)
escape_rust_keyword(&to_snake_case(name))
}
fn path_expr(&self, base_var: &str, suffix: &str) -> String {