rust
commandThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
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
&strinstead of CString (NUL-terminated strings). - Uses
std::mem::forgetto 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¶
There is no documentation for this package.