String

T parameter&T parameter&mut T parameterT return valueOption<T> parameterOption<T> return valueJavaScript representation
YesNoNoYesYesYesJavaScript string value

Copies the string's contents back and forth between the JavaScript garbage-collected heap and the Wasm linear memory with TextDecoder and TextEncoder

Note: Be sure to check out the documentation for str to learn about some caveats when working with strings between JS and Rust.

Example Rust Usage

{{#include ../../../../examples/guide-supported-types-examples/src/string.rs}}

Example JavaScript Usage

{{#include ../../../../examples/guide-supported-types-examples/string.js}}