Example Rust program running in LuaLaTeX via WebAssembly
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 17 lines 385 B view raw
1#[link(wasm_import_module = "tex")] 2unsafe extern "C" { 3 fn tex_putchar(c: i32); 4 fn tex_flush(); 5} 6 7#[unsafe(no_mangle)] 8pub extern "C" fn tex_hello(a: i32, b: i32) { 9 tex_sprint(&format!("Hello \\LaTeX{{}} from Rust! ${a} + {b} = {}$", a+b)); 10} 11 12fn tex_sprint(s: &str) { 13 for c in s.chars() { 14 unsafe { tex_putchar(c as i32) }; 15 } 16 unsafe { tex_flush() }; 17}