rust

command
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Rust allocation example

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

$ go run greet.go wazy
Hello, wazy!

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).
  • Uses std::mem::forget to prevent Rust from eagerly freeing pointers returned.

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL