Rust: How do I return a list<string>?
Given .wit like this
package example:q
world test {
export hello: func() -> list<string>;
}
and impl in rs:
wit_bindgen::generate!({
world: "test",
});
struct Test;
impl Guest for Test {
fn hello() -> Vec<String> {
vec!["hello".to_string(), "world".to_string()]
}
}
export!(test);
When I debug, the result is an empty array. Tried basically the same thing as above in this sample https://github.com/microsoft/vscode-extension-samples/tree/main/wasm-component-model w/ the same result.
I feel like I'm missing something fundamental here.
Thanks for the report! Are you able to share how this code is being called? What you're doing looks correct so the mistake may be on the host half rather than the guest half perhaps?
@alexcrichton hello yes I am using this sample, https://github.com/microsoft/vscode-extension-samples/tree/main/wasm-component-model
I added the hello function I defined in my issue to the calculator sample and then invoked it from the api object inside of the vscode command invocation. I can try to build an isolated example if that helps.
Yeah if you can build an isolated example that'd be great! Sorry I'm not familiar with vscode extensions so I'm not sure precisely how the component is being run.