walrus
walrus copied to clipboard
How do I convert a Rust string into a wasm local variable using walrus?
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?
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.