Generate wat in Rust

I'm not asking about compiling Rust to wasm or compiling Rust to wat.

I want my rust code to generate Wat.

I want to generate the exprs in

Is there some Rust crate for generating this? To clarify: I'm not asking about parsing/loading/compilingto wasm. I literally just want to generate wat on the fly.

One option for generating wat is Wasmtime which uses compilers to generate wat from Rust, C/C++ and AssemblyScript.

What WAT code you want to generate from Rust? WAT is a textual format and you can easily write it by hand on your favorite text editor.

It looks like binaryen-sys has a method for transforming a module AST into WAT:

It's an unsafe interface, but it's the only thing I've found that writes WAT.

1 Like

Lucet has a rust api to compile and link code.

Example use in their tests:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.