Movatterモバイル変換


[0]ホーム

URL:


rust

command
v1.10.1Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License:Apache-2.0Imports:7Imported by:0

Details

Repository

github.com/tetratelabs/wazero

Links

README

Rust allocation example

This example shows how to pass strings in and out of a Wasm function definedin Rust, built withcargo build --release --target wasm32-unknown-unknown

$ go run greet.go wazeroHello, wazero!

Under the covers,lib.rs does a few things of interest:

  • Uses a WebAssembly-tuned memory allocator:wee_alloc.
  • Exports wrapper functions to allocate and deallocate memory.
  • Uses&str instead of CString (NUL-terminated strings).
  • Usesstd::mem::forget to prevent Rust from eagerly freeing pointers returned.

Note: We chose to not use CString because it keeps the example similar to howyou would track memory for arbitrary blobs. We also watched function signaturescarefully as Rust compiles different WebAssembly signatures depending on theinput type.

Seehttps://wazero.io/languages/rust/ for more tips.

Documentation

The Go Gopher

There is no documentation for this package.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp