walrus icon indicating copy to clipboard operation
walrus copied to clipboard

How do I convert a Rust string into a wasm local variable using walrus?

Open clacladev opened this issue 1 year ago • 1 comments

Summary

I have a Rust string I want to represent it in a wasm function body as a local variable. How do I go about it with walrus? Is there any helper?

Additional Details

I found one way which should add one char at the time into a string. I found another way which uses module data to store the string. Are any of these strategies correct?

Are there other crates that can help me if walrus cannot?

clacladev avatar Aug 08 '24 17:08 clacladev

There really isn't a way to do it with locals. The "more correct" solution is the second one, where you store an offset to linear memory. Keep in mind, that there may not be other crates that can help you, as this is a thing specific to wasm, not the walrus implementation.

Germ210 avatar Feb 19 '25 07:02 Germ210