expression
Select a WebAssembly target by host contract
Wasm is a portable instruction format, not a browser or operating system. Choose a target based on host interfaces: unknown-unknown for a minimal host contract, wasip1 for WASI 0.1, wasip2 for WASI 0.2 components. This Rust model prints planned target names; it does not compile them. Expected host stdout (not executed): minimal: wasm32-unknown-unknown WASI 0.1: wasm32-wasip1 WASI 0.2: wasm32-wasip2 Common mistake: Choosing a target solely because the CPU architecture is Wasm.
Formal Syntax & Structure
rust syntaxrust
cargo build --target wasm32-unknown-unknownWorking Example
Example Snippetrust
fn main() { for (host, target) in [("minimal", "wasm32-unknown-unknown"), ("WASI 0.1", "wasm32-wasip1"), ("WASI 0.2", "wasm32-wasip2")] { println!("{host}: {target}"); }}