use fusevm::RustSugar;
fn emit(b64: &str, line: usize) -> String {
format!("__rust_compile \"{b64}\" {line}")
}
pub const SUGAR: RustSugar = RustSugar {
keyword: "rust",
line_comments: &["#"],
block_comment: None,
newline_boundary: true,
emit,
};
pub fn desugar(src: &str) -> String {
SUGAR.desugar(src)
}
#[cfg(test)]
mod tests {
#[test]
fn desugars_rust_block_at_line_start() {
let src =
"rust { pub extern \"C\" fn add(a: i64, b: i64) -> i64 { a + b } }\ngauge .g -max 42\n";
let out = super::desugar(src);
assert!(out.contains("__rust_compile"), "no builtin command: {out}");
assert!(!out.contains("pub extern"), "Rust body leaked: {out}");
assert!(
out.contains("gauge .g -max 42"),
"trailing spec dropped: {out}"
);
}
#[test]
fn leaves_ordinary_arb_untouched() {
let src = "source .g { in; count }\ngauge .g -max 8\n";
assert_eq!(super::desugar(src), src);
}
}